get amount of last array in php -
this question has answer here:
i working in codeigniter. have array parent , child display below.
array ( [id] => 27 [name] => mukesh chunawala [children] => array ( [0] => array ( [id] => 160 [name] => pravinbhai parmar [children] => array ( [0] => array ( [id] => 161 [name] => aratiben pravinbhai parmar [amnt] => 0 ) ) [amnt] => 0 ) [1] => array ( [id] => 188 [name] => pravinbhai parmar [amnt] => 0 ) [2] => array ( [id] => 189 [name] => amrishbhai s. chunawala [amnt] => 0 ) [3] => array ( [id] => 190 [name] => dharmesh rana [amnt] => 0 ) [4] => array ( [id] => 191 [name] => chadhri kavita [amnt] => 0 ) [5] => array ( [id] => 192 [name] => vasava shitalben [amnt] => 0 ) [6] => array ( [id] => 194 [name] => sudhaben r chunawala [amnt] => 0 ) [7] => array ( [id] => 195 [name] => sarojben r parmar [amnt] => 0 ) [8] => array ( [id] => 196 [name] => rabari.shantilal.b [amnt] => 0 ) [9] => array ( [id] => 197 [name] => poojabhai.a.bariya [amnt] => 0 ) [10] => array ( [id] => 198 [name] => lataben vasava [amnt] => 0 ) [11] => array ( [id] => 199 [name] => arvindbhai vasava [amnt] => 0 ) [12] => array ( [id] => 200 [name] => rohit varshaben lalitbhai [amnt] => 0 ) [13] => array ( [id] => 201 [name] => chhatrivala hinaben harishbhai [amnt] => 40 ) [14] => array ( [id] => 202 [name] => manishaben chunawala [amnt] => 40 ) [15] => array ( [id] => 203 [name] => kalpana j rana [amnt] => 40 ) [16] => array ( [id] => 204 [name] => chunawala shaileshkumar g [amnt] => 40 ) [17] => array ( [id] => 205 [name] => anitaben.b rajput [amnt] => 184 ) [18] => array ( [id] => 206 [name] => vasantbhai vasava [amnt] => 184 ) [19] => array ( [id] => 207 [name] => vasant.f.vasava [amnt] => 328 ) [20] => array ( [id] => 208 [name] => salat sadikhusen gulammahammad [amnt] => 376 ) [21] => array ( [id] => 211 [name] => ranjit b vasava [amnt] => 376 ) [22] => array ( [id] => 212 [name] => jivanbhai p vaghela [amnt] => 376 ) [23] => array ( [id] => 214 [name] => rameshbhai bariya [amnt] => 376 ) [24] => array ( [id] => 215 [name] => mansuri saleembhai rasulbhai [amnt] => 376 ) [25] => array ( [id] => 218 [name] => mansuri saleembhai rasulbhai [children] => array ( [0] => array ( [id] => 161 [name] => aratiben pravinbhai parmar [amnt] => 616 ) ) [amnt] => 616 ) [26] => array ( [id] => 219 [name] => bharatbhai vankar [amnt] => 616 ) [27] => array ( [id] => 221 [name] => mustufakhan k pathan [amnt] => 616 ) ) )
now, want fetch amount of last id.here, last id 27. want fetch amount of 27 id. code should have write amount of last id?
and want name parent array code should have write?
$last = end($your_array['children']); $amt = $last['amnt'];
note end()
advances array's internal pointer last element.
Comments
Post a Comment