How to Convert String into Array in PHP?
In this short tutorial we will cover an how to convert string into array in php. step by step explain how to convert string value into array in php. I would like to share with you php convert string to array by comma. you'll learn php convert string to array with delimiter. follow bellow step for how to create array from string in php.
We will use explode() to convert string to array in PHP. explode() provide ways to convert a string into an array using a delimiter. I will give you two examples that way you can understand how it works.
Let's see below example:
$myString = "Hi, I am ItSolutionStuff.com";
$array = explode(' ', $myString);
 => Hi,
 => I
 => am
 => ItSolutionStuff.com
$myString = "Rajkot,Surat,Bhavnagar,Baroda";
$array = explode(',', $myString);
 => Rajkot
 => Surat
 => Bhavnagar
 => Baroda
I hope it can help you...
We are Recommending you
- PHP Multidimensional Array Search By Value Example
- PHP Check If Array Is Multidimensional or Not
- How to Remove Multiple Keys from PHP Array?
- How to Remove Specific Element by Value from Array in PHP?
- How to Remove undefined Value from Array in JQuery?
- How to Get Maximum Key Value of Array in PHP?
- How to Remove Empty Values from Array in PHP?
- How to Add Prefix in Each Key of PHP Array?
- How to Get Minimum Key Value of Array in PHP?
- How to Remove Null Values from Array in PHP?
- How to Merge Two Array with Same Keys without Loop in PHP?