I have an array like this:
Array ( [0] => B121933, [1] => B105885, [1] => B105886 )
I need it in this format:
array('B121933','B105885','B105886')
I have used below code but it returns the same result:
foreach ($_finder_sku_array as $key => $value) {
$arr[] = $value;
}
print_r($arr);
Array ( [0] => B121933 [1] => B105885 [2] => B105886 )
So please suggest an idea on how I can get a proper result.
Andprint_r(array('B121933','B105885','B105886'));
will show you :
Array ( [0] => B121933 [1] => B105885 [2] => B105886 );
try this :
$array = array_values($array);
This function converts the passed array in the string format you require.
<?php
function arr_to_string($array){
$new_array='array("';
for($i=0;$i<sizeof($array)-1;$i++) {
$new_array.=$array[$i].'","';
}
$new_array.=$array[sizeof($array)-1].'")';
return $new_array;
}
$array=array("B121933","B105885","B105886");
echo arr_to_string($array); // Outputs array("B121933","B105885","B105886")
?>