Wednesday, 2 October 2013

PHP store 2 values into 1 array index

PHP store 2 values into 1 array index

Hi sorry for the relatively newbie question
Im trying to create a sort of multidimensional array which takes 2 values
from a database and stores in into 1 index in the array
Example x[0] = Jille, 595
Im doing this as such
while ($row = mysql_fetch_array($result2))
{
$opponents[] = $row['opponents'];
$fixId= array($row['fixture_id'] => $opponents) ; //Is this line correct??
}
Then later on in my code I want to use the $fixId array which should hold
2 values per index I do this as such:
foreach($fixid as $id => $oppname){
echo "<option value=\"$oppname\" >".$oppname;"</option>";
}
However it is not working the values $id and $oppname does not have a
value or take on some strange value.
Ive been stuck on this for the past few hours if anybody can give me some
advice to what am I doing wrong it will be greatfully appreciated

No comments:

Post a Comment