What are some PHP basics that can be helpful in manipulating arrays and iterating through directory contents?

When working with arrays in PHP, it's important to understand how to manipulate them by adding, removing, or accessing elements. Additionally, iterating through directory contents can be useful when dealing with file management tasks. By using PHP functions like `array_push()`, `unset()`, `foreach()`, and `scandir()`, you can effectively manipulate arrays and iterate through directory contents.

// Manipulating arrays
$myArray = [1, 2, 3, 4, 5];

// Adding elements to an array
array_push($myArray, 6);

// Removing an element from an array
unset($myArray[2]);

// Iterating through an array
foreach($myArray as $element) {
    echo $element . " ";
}

// Iterating through directory contents
$directory = 'path/to/directory';
$files = scandir($directory);

foreach($files as $file) {
    echo $file . "<br>";
}