I'm grabbing data out of an API, and every once in a while, a value comes back in one of the fields I'm capturing that has a comma in it, which is causing my results to be offset by 1 each time it happens.
after I've gotten the results from the API, I put it into $answerSearch, then I json_decode it.
$json = json_decode($answerSearch, true);
foreach ($json['Result']['a']['b'] as $i) {
$y = "{$i['number']},{$i['Type']},{$i['c']},{$i['d']},{$i['e']}";
$x = explode("," , $y);
array_push($output, $x);
}
One of these {$i['number']} values may be "1234,123", and because I use comma as a delimiter, it's causing the entire array to screw up.
How do I tell PHP that the , in the middle of this string is part of the string and not a delimeter?
Update
I can't just change $x = explode("," , $y); to use another delimiter because ,, /, ;, etc are all used in the actual strings that are being returned, I was just using , as an example.
$iis already an array, so why convert that array to a string, just to explode it back to an array? If you're doing this to copy only the keys you want, there's better ways of doing this...number, type, c, d, and e), and this code does that.