RE: [PHP] How to get the key of a specific index of array?

From: Date: Wed, 19 Nov 2003 13:12:32 +0000
Subject: RE: [PHP] How to get the key of a specific index of array?
Groups: php.general 
Request: Send a blank email to php-general+get-170271@lists.php.net to get a copy of this message
On 19 November 2003 12:59, David Strencsev contributed these pearls of wisdom: > "Wouter Van Vliet" <wouter@springt.nl> wrote in message > news:NMEAKPCLPANNJPNMHPNGAEIDCAAA.wouter@springt.nl... >> >> First of all, you said to use the first three values of the > array for > anoter >> reason .. well the, what I'd do is this: >> >> $FirstThree = array_splice($_POST, 0, 3); >> >> Which will give you the first three elements of the array, >> and leave you with a $_POST array you can do foreach with. > > Great! Thanks! I think it will be very useful. > > >> Second, to manually loop through an array, use: >> http://nl.php.net/manual/en/function.prev.php >> http://nl.php.net/manual/en/function.next.php >> http://nl.php.net/manual/en/function.current.php >> http://nl.php.net/manual/en/function.reset.php >> http://nl.php.net/manual/en/function.end.php > > Yes, I know these functions, but I'm still wondering if > there's a DIRECT way > to move an array's internal pointer to a specific position > and/or key. As someone else said before, I feel you may be thinking in the wrong direction. If you could give us a couple of examples of data you might expect to see in your $_POST aray, and what you wish to produce from it -- e.g. a sample of the final results from the provided data -- we might be able to provide the *real* solution to your problem, not try to shoehorn it into what might be an inappropriate one. In short, give us (a) sample input and (b) desired output, and see what suggestions come up for getting from (a) to (b) -- you might be surprised at how different they are from what you expect! ;) Cheers! Mike -- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: m.ford@leedsmet.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#170271) next »