Retrieve value from array in cakePHP -
i want know how retrieve values array looking that:
array ( [0] => array ( [group] => array ( [id] => 1 [name] => admin [created] => 2013-04-15 14:13:19 [modified] => 2013-04-15 14:13:19 ) [admin] => array ( [0] => array ( [id] => 1 [email] => iman@yahoo.com [username] => iman [password] => 9e217e2039912c40b0f179f801e2d3e9fe8eb32e [active] => 1 [mobile] => 01000000000 [created] => 2013-04-15 13:56:02 [modified] => 2013-04-15 14:44:59 [group_id] => 1 [tokenhash] => e2e1bbffc40d3f909594a268f0f3ec127fabe5c00e01c5f0644a1950aa37e6103ad18542a8731a2ad9ade283916281977677523098cd25a296116d078fbbc231 [image] => d )...
thanks.
what have tried already?
as far can see based on limited information provided, have 2 options; access value directly providing relevant keys or looping on array.
say want access name
of first group
in array, presume stored in variable (called $yourarray
in example):
$yourarray[0]['group']['name']
the result 'admin'.
looping give benefit of retrieving group names (or other value):
foreach ($yourarray $value) { //output group name echo $value['group']['name']; //output admin email echo $value['admin'][0]['email']; }
but above standard php stuff , not specific cakephp. might read on basics of php well, cakephp adds layer of abstraction providing kinds of framework conventions , convenience methods.
Comments
Post a Comment