PHP check array contain multiple sub arrays with data array OR just one data array -


i got array call api , need parse it. return single data array this

array{    [name] => aaa    [address] => bbb    [country] => ccc } 

or return multiple data arrays this

array{    [0]=>array{       [name] => aaa       [address] => bbb       [country] => ccc    }     [1]=>array{       [name] => qqq       [address] => www       [country] => eee    }     [2]=>array{       [name] => ttt       [address] => yyy       [country] => uuu    } } 

what best way determine return array contain multiple arrays? or if statement it? know how write function , return or not. foreach check is_array return
there express way or php function can it?

you can use isset know wether or not first index number (multi-dimensional) or not (uni-dimensional):

if (isset($array[0]) {     // since index 0 not key 'name'     // array multi-dimensional } else {     // since first index not 0, array     // uni-dimensional } 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -