キーに基づいて配列から値を取得しようとしています。
私は持っています
$array1{
 '0' =>'text1',
 '1' =>'text2',
 '2' =>'text3'
}
$array2{
 '0' =>'123',
 '1' =>'456',
 '2' =>'789'
}
 //$source could be text1,text2 or text3
 //I want to show 123, 456 or 789 based on the value passed in
       if(in_array($source, $array1)){
         $id=array_keys($array1,$source);
         echo $array2[$id];
       }
illegal offset typeのせいで''というエラーが発生しました$array2[$id]。
とにかくこれを修正することはありますか?どうもありがとう!