André Cardoso
André Cardoso

Reputation: 115

Help with big array

I have this array:

$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")
        )
    )
);

I'm trying to make it so i get a string, if strpos finds 'barra' it tries to fin 'sao conrado' or 'elevado do joa' if it finds it it returns it's coordinates, is there a better way to do it ? this is the best I could do but I don't think this is the best way to do it because it will have to loop everytime to find 'barra', 'recreio', etc

help

Upvotes: 0

Views: 75

Answers (1)

RobertPitt
RobertPitt

Reputation: 57268

Try something like this:

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

Upvotes: 1

Related Questions