PHP explode() Function Example Tutorial

Posted by

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.


Get Started Now!

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

Your email address will not be published. Required fields are marked *

0
Would love your thoughts, please comment.x
()
x