Vijay K October 8, 2023 0

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!

We will go over how to transform a string into an array in PHP in this little tutorial. Describe how to convert a string value into an array in PHP step by step. I’d like to share with you how to transform a string using a comma in PHP. Learn how to use a delimiter in PHP to transform a string into an array. To learn how to generate an array in PHP from a string, follow the steps below.

We’ll utilize PHP’s explode() function to transform a string into an array. Using a delimiter, explode() offers methods for turning a string into an array. In order for you to comprehend how it functions, let me give you two instances.

Example:- 1

<?php
  
$myString = "Hi, I am devopsschool.com";
   
$array = explode(' ', $myString);
  
print_r($array);

?>

Output:

Example:- 2

<?php
  
$myString = "Rajkot,Surat,Bhavnagar,Baroda";
  
$array = explode(',', $myString);
  
print_r($array);

?>

Output:

Category: 
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments