Created
November 7, 2017 17:58
-
-
Save Sstobo/7e38fcae185efdd967fb05d0093363b5 to your computer and use it in GitHub Desktop.
[PHP array implode explode] #php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| To convert array items into a comma-separated string, use the implode() function: | |
| $skills = array( 'html', 'css', 'js', 'php' ); | |
| $comma_separated = implode(',', $array); | |
| echo $comma_separated; // output: html,css,js,php | |
| You can also convert a string to an array using the explode() function: | |
| $skills = 'html css js php'; | |
| $skills_array = explode( ' ', $skills ); | |
| print_r( $skills_array ); | |
| // output: Array ( [0] => html [1] => css [2] => js [3] => php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment