What PHP function can be used to split a string based on a delimiter like a comma?
To split a string based on a delimiter like a comma in PHP, you can use the `explode()` function. This function takes two parameters: the delimiter (in this case, a comma) and the string to be split. It returns an array of substrings that were separated by the delimiter.
$string = "apple,banana,orange";
$delimiter = ",";
$split_array = explode($delimiter, $string);
print_r($split_array);
Related Questions
- What are some potential challenges when using TCPDF to create multi-page PDF documents with dynamically sized tables in PHP?
- What are the differences in behavior between running PHP locally (e.g. XAMPP) and on a live server in terms of session handling?
- How can I create a field-based history for tracking changes in a database using PHP?