PHP explode() Function Example Tutorial

Posted by

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:-

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x