I can not start the array on the server

1

Locally the data leaves, but hosted does not work.

function teste(){
    return array(
        "importancia" => array(
            "Customer el",
            "Over ",
            "Ovedde (MPG)"
        ),
        "dados"=> array(
            "Customer care: xthe sdsdel",
            "Overall d.",
            "asd"
        ),
        "question"=> array(
            "Icvxcv",
            "Iasdasd"
        )
    );
}


$teste = teste()['importancia'];
echo count($teste);

locally appears echo = 3; now when I host the page on the server, the page is simply blank.

The external host version is 5.3.3-7 and the one installed on my computer is 5.5.9.

    
asked by anonymous 23.09.2015 / 21:15

1 answer

1

The way is to adapt the syntax of php to version 5.3, it's very simple, get the function return and call the key in count() .

This functionality array and string literal dereferencing , is available in versions 5.5 or higher of php.

$teste = teste();
echo count($teste['importancia']);

Related:

What is the purpose of Array and String Dereferencing implemented in PHP 5.5?

    
23.09.2015 / 21:22