How to split in PHP?

I want to split a string in PHP into two to separate two strings wherever there is a comma. For example let’s say we have a string this is, my string. I want to make this is and my string into two separated strings. Then I want to assign them into different variables so that I can use them separately. How can I do that?

You can use the explode() function to split strings at a specific separator. This is how it works.

$string = "this is, my string";
$value = explode(', ', $string);

This will return an array of the split strings this is and my string.