How to convert a sting into an array using php

In PHP, a string can be converted into an array using the explode() function. It separates the string into multiple elements based on a specified delimiter and returns them as an array.

By Technology
How to convert a sting into an array using php

PHP is also known as a hypertext programming language. You can convert a string of characters into an array using the PHP "explode" function. Many of the programmers who started their career in the software field always stuck at this point of the program where the problem can solve by converting the string into an array. As a beginner, I also face the same issue as to how I can convert a string into an array.

Explode function:-  explode('delimiter','srting');

<?php 

$a="MY Name is Example";
explode(' ',$a);
foreach($a as $row){
echo $row;
}

?>

Also, You can do the reverse of this operation by converting the array into a string by the "implode" function.

php-2060502_640 (1).jpg

Implode function:- implode('delimiter','array');

<?php 

$a = array('My','name','is','example');
echo implode(" ",$a);

?>

← Back to World Gossip