Hi,
I am having trouble getting my syntax correct. Any help would be very much appreciated. Basically i have 2 arrays. The first array is stuctured like this
$categoryarray -- Array
(
[1960's] => Array
(
[id] => 11
[value] => 0
)
[1980's] => Array
(
[id] => 12
[value] => 0
)
[Artists] => Array
(
[id] => 1
[value] => 0
)
[Bands] => Array
(
[id] => 2
[value] => 0
)
[Clothing Designers] => Array
(
[id] => 4
[value] => 0
)
[Computers] => Array
(
[id] => 3
[value] => 0
)
[Furniture Designers] => Array
(
[id] => 5
[value] => 0
)
[Movies] => Array
(
[id] => 6
[value] => 0
)
[Musical Intruments] => Array
(
[id] => 7
[value] => 0
)
[People] => Array
(
[id] => 8
[value] => 0
)
[Science] => Array
(
[id] => 9
[value] => 0
)
[Swatch Watch] => Array
(
[id] => 13
[value] => 0
)
[TV Shows] => Array
(
[id] => 10
[value] => 0
)
)
The second array comes from the checkboxes in an html form.(this is just an example of sample input)
$formarray -- Array
(
[0] => 1980's
[1] => Bands
[2] => Computers
[3] => Movies
[4] => People
[5] => Swatch Watch
)
So what i am trying to do is change the 'value' in the first array from 0 to 1 if the category appears in the second array. I hope that makes sense. anyway, i have this which is not correct.
foreach($categoryarray as $array1 => $value1)
{ foreach($formarray as $array2 => $value2)
{ if($array1 == $value2) $categoryarray [$value2] = 1;
}
}
it gives an output of this, so how can i push that 1 down to the 'value' field?
$categoryarray -- Array
(
[1960's] => Array
(
[id] => 11
[value] => 0
)
[1980's] => 1
[Artists] => Array
(
[id] => 1
[value] => 0
)
[Bands] => 1
[Clothing Designers] => Array
(
[id] => 4
[value] => 0
)
[Computers] => 1
[Furniture Designers] => Array
(
[id] => 5
[value] => 0
)
[Movies] => 1
[Musical Intruments] => Array
(
[id] => 7
[value] => 0
)
[People] => 1
[Science] => Array
(
[id] => 9
[value] => 0
)
[Swatch Watch] => 1
[TV Shows] => Array
(
[id] => 10
[value] => 0
)
)