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 value from php array?
- How to remove undefined value from jquery array?
- 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 ?