PHP在foreach循环中设置值

i have a problem with in
i tried to execute this code but at the end $part does not include bought
what's the problem?

foreach ($parts as $part){

     foreach ($boughtParts as $boughtPart){

            if($part['part_id'] == $boughtPart['part_id'])
                  $part['bought'] = 1;

     }

}

Try this : foreach ($parts as &$part)

This will be passed by reference, but until now you were doing a copy.