开发者

Can i retrieve array value not using loop?

is there a way to retrieve array value not using any loop function? I have this sort of array

$at=array(
    array(
        array('Title:','titl','s'开发者_JAVA技巧,'c',$titles),
        array('First Name:','name','i','A',2,10 ),
    ),


try array_values

Sorry this one was suppose to be a comment.


Your example looks like it's probably one level too deep, but to directly work with a more basic example:

$at=array( array('Title:','titl','s','c',$titles), array('First Name:','name','i','A',2,10 )

list($title, $something, $foo, $bar) = current($at);

echo $title;


Yes, you can.

for example $at[0], $at[1], $at[2]

When an array hasn't been assigned keys, the keys ( in the above example keys would be 0 1 and 2) ascend numerically from 0.

For an array with keys (such as $at = array('key' => 'value', 'key2' => 'value2') ), you can access the properties as $at['key'], $at['key2'] ( note the quotes wrapping the key name )

Hope this is of use to you!

Cheers!, Pedro


you need to know the key of the value you want to select

  echo $at[0];
  echo $at[0][0];
  echo $at[0][3];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜