I’m trying to figure this out…
I have a string like this:
$string = '1,john,43,2,peter,51,3,jeff,50,5,nick,46';
The string is like this: placement,name,age
So to get this out in an array I do this:
$array = explode(",",$string);
$h = '';
$k = 0;
foreach($array as $value){
$h .= ($k%3 == 2)?$value.';':$value.',';
$k++;
}
$newarray = explode(";",substr($h,0,-1));
Now I have an array like this
Array
(
[0] => 1,john,43
[1] => 2,peter,51
[2] => 3,jeff,50
[3] => 5,nick,46
)
Now what I want now is to be able to get the placement out of the array and find the missing placement (4) and make that into an variable… Just dont know where to start?
Please help and thanks in advance:-)