帮助大阵列

时间:2011-05-05 14:15:16

标签: php arrays string

我有这个数组:

$array_lugares = array
(
    array("barra"=>array
        (
            /*SENTIDO BARRA*/
            "Sao conrado"=>array("-22.999743","-43.270694"),
            "Elevado do Joa"=>array("-22.999429","-43.27317")
        ),
        "zona sul"=>array
        (
            /*SENTIDO ZONA SUL:*/
            "passarela barra"=>array("-23.008346","-43.303708"),
            "barra grill"=>array("-23,010576", "-43,302028"),
            "lagoa barra"=>array("-22,997348", "-43,263200")
        ),
        "recreio"=>array(
            /*SENTIDO RECREIO:*/
            "passarela barra"=>array("-23.008283","-43.303634"),
            "rio mar"=>array("22.999958","-43.402648"),
            "ribalta"=>array("-22,999753", "-43,409211")
        )
    )
);

我正在尝试这样做,所以我得到一个字符串,如果strpos发现'barra'它试图鳍'sao conrado'或'elevado do joa'如果它发现它返回它的坐标,是否有更好的方法去做吧 ?这是我能做的最好的,但我不认为这是最好的方法,因为它必须每次循环才能找到'barra','recreio'等等

帮助

1 个答案:

答案 0 :(得分:1)

尝试这样的事情:

if(isset($array_lugares[0]['barra']['Sao conrado']))
{
    //Exists
}