0perator Posted June 19, 2008 Share Posted June 19, 2008 Array ( [0] => black market [1] => internet protocol (IP) [2] => microshit (M$) [3] => prism2 [4] => omg (Oh My God) [5] => pfSense [6] => hackers 2 - operation takedown [7] => nullbyte (%00) [8] => hypertext markup language (HTML) [9] => blue screen of death (BSoD) [10] => cyper [11] => redhat package management (RPM) [12] => h4x0r [13] => pseudonym [14] => hackers [15] => cracker [16] => iceweasil [17] => code auditing [18] => redhat package management (RPM) [19] => repository [20] => sql injection [21] => ) thats the result of print_r($panagram) now, the last entry into the array is not always 21. so, how do i delete the last entry, i tried unset(end($panagram)); no luck. cheers guys. Quote Link to comment https://forums.phpfreaks.com/topic/110900-array/ Share on other sites More sharing options...
bluejay002 Posted June 19, 2008 Share Posted June 19, 2008 so you mean you only want to create an array upto 21 only, is that right? Quote Link to comment https://forums.phpfreaks.com/topic/110900-array/#findComment-568959 Share on other sites More sharing options...
bluejay002 Posted June 19, 2008 Share Posted June 19, 2008 anyway, bout removing specific array items, you can use array_slice() and/or array_pop(). Quote Link to comment https://forums.phpfreaks.com/topic/110900-array/#findComment-568961 Share on other sites More sharing options...
kev wood Posted June 19, 2008 Share Posted June 19, 2008 if you know how many parts there are to the array then you could use something like unset($array_name[21]) Quote Link to comment https://forums.phpfreaks.com/topic/110900-array/#findComment-568968 Share on other sites More sharing options...
0perator Posted June 19, 2008 Author Share Posted June 19, 2008 thanks, but how do i get the value of the key at end() Quote Link to comment https://forums.phpfreaks.com/topic/110900-array/#findComment-568972 Share on other sites More sharing options...
kev wood Posted June 19, 2008 Share Posted June 19, 2008 i have not tested any of this code but it this should get the length of the array $length= count($array_name); this should give you the number of elements held with in the array Quote Link to comment https://forums.phpfreaks.com/topic/110900-array/#findComment-568978 Share on other sites More sharing options...
sasa Posted June 19, 2008 Share Posted June 19, 2008 look array_pop() function Quote Link to comment https://forums.phpfreaks.com/topic/110900-array/#findComment-569042 Share on other sites More sharing options...
bluejay002 Posted June 20, 2008 Share Posted June 20, 2008 you can use this: <?php $array = array('wed'=>'sample1','thu'=>'sample2','fri'=>'sample3'); end($array); $key = key($array); echo $key. "<br><br>"; ?> cheers, Jay Quote Link to comment https://forums.phpfreaks.com/topic/110900-array/#findComment-569750 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.