Hello gurus,
I've been pounding my head against the wall on this one. It must be something simple I'm missing. I have a text field that posts ($_POST['case_ids']) a comma separated value such as 10067,10076 When I use explode to break it up it should make it an array. However when I use it in a foreach loop I get an invalid argument error. If I do a check for is_array() it fails the check.
If I print the array I get:
Array ( [0] => 10067 [1] => 10076 )
So I thought maybe I get the error because the individual array elements don't have commas between them so I wrote this to put commas in between each element except the last:
$cases = array();
$numItems = count($case_ids);//get count of array
$i = 0;//initialize counter
foreach($case_ids as $key => $value){
if($i+1 != $numItems) {
$cases[$key] = $value.',';
}else{
$cases[$key] = $value;
}//end if $i+1
$i++;
}
However this new array still gets the invalid argument error. Are these not valid arrays?
Any help would be greatly appreciated.
Thanks in advance,
Twitch