0

I am sure this is something simple, but I can't find it anywhere:

How can I change an array like this:

{ [0]=> string(3) "674" [1]=> string(3) "675" [2]=> string(3) "676" [3]=> string(3) "677" } 

into a simple one like this:

(674,675,676,677)

For use in another SQL (IN) query?

I have tried imploding and it fails.

$myarray_value = implode( ',', $myarray );
Stephen
  • 8,038
  • 6
  • 41
  • 59

1 Answers1

2

What you are looking at is in JSON format, so just do this:

$string = '{ [0]=> string(3) "674" [1]=> string(3) "675" [2]=> string(3) "676" [3]=> string(3) "677" }';
$array = json_decode($string);
print_r($array);
TravisO
  • 9,406
  • 4
  • 36
  • 44