Re: How to get the key of a specific index of array?

From: Date: Wed, 19 Nov 2003 12:59:18 +0000
Subject: Re: How to get the key of a specific index of array?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-170267@lists.php.net to get a copy of this message
"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. > Third, don't rely on the order your array elements are given to you by post > data. Rather just use foreach() and (ignore|do something else with) the > key-value pairs you don't want for this thing. But if these required three keys are messed up into the $_POST array, Is there a direct way to shift off elements at a specified key or index to remove them from an array? (I mean without a batch process) Something like: array_shift($array, $index) which of course is incorrect Although now I know I can write a code to search for a key and then splice it out from $_POST into another one. Thanks! > Fourth, I hope I'm not spoiling Jay Blanchard statement on how uncredibly > great this online PHP Manual is since you could probably find all the > answers to array related questions right here: > http://nl.php.net/manual/en/ref.array.php Thanks... I'm reading the online manual and many other sites before posting to newsgroups, As you can see, I'm not an expert programer but just a beginner. I'm trying to make a lightweight any-form-to-email script. The first 3 keys of the associative array ($_POST) are "recipient", "reply_email" and "subject". All other NAMED form elements will be mailed with this format: FORM NAME (key): FORM VALUE (value) - PhiSYS

« previous php.general (#170267) next »