MDanz Posted June 1, 2011 Share Posted June 1, 2011 How do i do if i've reached of array? i know i could do end of loop. but the array is present many times in my code. while($row = mysql_fetch_assoc($getdetails)) { $people = $row['people']; $_SESSION['people'][] = $people; if(end($_SESSION['people'])) { //code } } Link to comment https://forums.phpfreaks.com/topic/238146-if-end-of-array-in-loop-help/ Share on other sites More sharing options...
Alex Posted June 1, 2011 Share Posted June 1, 2011 I'm not entirely sure what you're asking, can you try reforming the question? Link to comment https://forums.phpfreaks.com/topic/238146-if-end-of-array-in-loop-help/#findComment-1223749 Share on other sites More sharing options...
MDanz Posted June 1, 2011 Author Share Posted June 1, 2011 $_SESSION['people'] is an array. I add to $_SESSION['people'] by doing this... $_SESSION['people'][] = $people; basically how do i code "if last key in array?".. i tried this but it's not correct if(end($_SESSION['people'])) { //code } Link to comment https://forums.phpfreaks.com/topic/238146-if-end-of-array-in-loop-help/#findComment-1223759 Share on other sites More sharing options...
MDanz Posted June 1, 2011 Author Share Posted June 1, 2011 nvm.. i got the solution end($array); $lastKey = key($array); Link to comment https://forums.phpfreaks.com/topic/238146-if-end-of-array-in-loop-help/#findComment-1223761 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.