PHP convert string into array; Through this tutorial, i am going to show you how to convert string into array with delimeters in PHP using explode() function.
PHP explode() function is used to convert a string or a comma-separated string into an array.
How to Convert a String Into Array in PHP
Use the below given examples to convert string into array using delimeters in PHP; as follows:
- PHP convert string into an array
- Convert string to array with delimiter php
PHP convert string into an array
Use the below given example to convert string to array with space delimiter php; is as follows:
<?php $string = "I love PHP"; print_r (explode(" ",$string)); ?>
The output of the above given code; is as follows:
Array ( [0] => I [1] => love [2] => PHP )
Convert string to array with delimiter php
Use the below given example to convert string to array with – delimiter php; is as follows:
<?php $nStr = "001-234-567678"; print_r (explode("-",$nStr)); ?>
The output of the above given code; is as follows:
Array ( [0] => 001 [1] => 234 [2] => 567678 )
Recommended PHP Tutorials
Recommended:-How to Update Data From Database in PHP
Recommended:-CRUD Operations in PHP MySQL with Bootstrap
Recommended:-PHP MySQL Ajax Add Edit Delete Same Page
Recommended:-PHP Ajax Live Search From MySQL Database
Recommended:-PHP MySQL Ajax Autocomplete TextBox From DB Example
Recommended:-Form validation using jQuery in PHP
Recommended:-PHP + MySQL Login Form with Session
Recommended:-PHP + MySQL Registration Form with Validation
Recommended:-PHP Ajax Form Submit with Validation Example
Recommended:-Ajax Get Data From MySQL Database in PHP
Recommended:-Google Places Autocomplete in PHP
Recommended:-PHP + MySQL + jQuery Signature Pad
Recommended:-Country State City Dropdown in PHP + MySQL + Ajax
Recommended:-PHP Send Reset Password Link Email
Recommended:-Star Rating System In PHP + MySQL + Ajax
Recommended:-Category Subcategory Dropdown in PHP + MySQL + Ajax
Recommended:-PHP + Ajax Upload Multiple Image with Preview
Recommended:-PHP Upload File to AWS S3 Bucket
Recommended:-Import CSV File Into MySQL Database using PHP
Recommended:-PHP + Ajax Import CSV File Into MySQL Database
Recommended:-PHP + MySQL Login and Registration Form using XAMPP
Recommended:-Import json File Data Into MySQL Database in PHP
Recommended:-PHP Subtract Days, Month, Year From Date
Recommended:-PHP Add Days, Month, Year From Date
Recommended:-How to change max file upload size in php ini Ubuntu
Recommended:-How to Get Next Day, Month, Year From Date In Php