I have values like
"34,37"
and I want to create array using this values, array like
array('34','37')
How to create such array if I have values.
I have values like
"34,37"
and I want to create array using this values, array like
array('34','37')
How to create such array if I have values.
hope this will help you :
you can use explode
function if you have values as string;
$string = '34,37';
$data = explode(',',$string):
print_r($data); /*output array*/
As per my comment, you should use preg_split
function. for more details about preg_split
function please read PHP manual and also you can use explode
function Explode function PHP manual
<?php
$string = '34,37';
$keywords = preg_split("/[\s,]+/", $string);
//OR $keywords = preg_split("/,/", $string); separated by comma only
print_r($keywords);
you can check your desired Output here
If you have a string like this:
$str = "1,2,3,4,5,6";
And you want to convert it into array, just use explode()
$myArray = explode(',', $str);
var_dump($myArray);
Have a look here for more information