What are some common methods in PHP to split and evaluate strings with variable lengths, such as in the given examples?
When dealing with strings of variable lengths in PHP, common methods to split and evaluate them include using functions like `explode()`, `substr()`, `preg_split()`, and regular expressions. These functions allow you to break down a string into smaller parts based on specific delimiters or patterns, making it easier to manipulate and evaluate the data within the string.
// Example: Splitting a string by a specific delimiter
$string = "apple,banana,orange";
$fruits = explode(",", $string);
print_r($fruits);
// Example: Extracting a substring with variable length
$string = "Hello, World!";
$substring = substr($string, 0, 5);
echo $substring;
// Example: Splitting a string using a regular expression
$string = "The quick brown fox jumps over the lazy dog";
$words = preg_split("/\s+/", $string);
print_r($words);