How to create array of comma separated string using PHP

[dm_code_snippet background=”yes” background-mobile=”yes” bg-color=”#abb8c3″ theme=”dark” language=”php” wrapped=”no”]

<?php

$codelizar_str = “857,965,57,224,7”; /* Input String */
$codelizar_array = explode (“,”, $codelizar_str);

print_r($codelizar_array); /* Output */

?>

[/dm_code_snippet]

Output

Array
(
[0] => 857
[1] => 965
[2] => 57
[3] => 224
[4] => 7
)

Leave a Reply

Your email address will not be published. Required fields are marked *