How to split a string into an array based on a delimiter in PHP?

In PHP, you can use the explode() function to split a string into an array based on a delimiter. Here's an example:

$string = "Hello,World,How,Are,You"; $delimiter = ","; $array = explode($delimiter, $string); print_r($array);

Output:

Array ( [0] => Hello [1] => World [2] => How [3] => Are [4] => You )

In the example above, we have a string stored in the variable $string and a delimiter (in this case, a comma) stored in the variable $delimiter. Then, we use the explode() function to split the string into an array based on the delimiter. Finally, we print the resulting array using print_r().