How can PHP differentiate between a number and a string when reading files from a directory?

When reading files from a directory in PHP, you can use the `is_numeric()` function to differentiate between a number and a string. This function checks if a variable is a number or a numeric string. By using this function, you can determine the type of data you are working with and handle it accordingly in your code.

$files = scandir('/path/to/directory');
foreach($files as $file){
    if(is_numeric($file)){
        // Handle as a number
        echo "Number: $file\n";
    } else {
        // Handle as a string
        echo "String: $file\n";
    }
}