codingtcher.com
Theme Night
Home
Login

Convert comma separated string to array php

Home » Tutorial Post » Convert comma separated string to array php

explode comma php

$myString = "9,[email protected],8";
$myArray = explode(',', $myString);
print_r($myArray);

php Convert String containing commas to array

$string = "'1', '2', '3'"; 
$string = str_replace("'", '', $string);

$sql = "SELECT * FROM name WHERE id NOT IN ( " . implode(",", explode(',',$string)) . ") LIMIT 10 ";
echo $sql;

array to string separated by comma php

$arr = array ( 0 => "lorem", 1 => "ipsum", 2 => "dolor");

$str = implode (", ", $arr);
Source: stackoverflow.com

Related Post