Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!
We spend hours scrolling social media and waste money on things we forget, but won’t spend 30 minutes a day earning certifications that can change our lives.
Master in DevOps, SRE, DevSecOps & MLOps by DevOps School!
Learn from Guru Rajesh Kumar and double your salary in just one year.
A PHP explode function example is given in this article. I will demonstrate how to use PHP’s explode string to array function. This is a basic example of using explode to split a string into an array in PHP. You will find a basic example of the explode function in a PHP example in this post. An array is created by the PHP explode() function from a string. Three arguments are required for explode(): limit, string, and separator. Limit is not required.
Syntax:
explode(separator,string,limit)
Example:-
<?php
$myString = "Hi, I am Vijay Kumar Pramanik";
$array = explode(' ', $myString);
print_r($array);
?>
Output:-

Example:- 2
<?php
$myString = "Bokaro, Ramgarh, Phusro, Gomia";
$array = explode(',', $myString, 3);
print_r($array);
?>
Output:-

Leave a Reply