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 } } Quote 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? Quote 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 } Quote 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); Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.