> -----Oorspronkelijk bericht-----
> Van: PhiSYS [mailto:[EMAIL PROTECTED]
>
> How to get the key of a specific index of array?
>
> It seems that key($_POST[$i]) is a wrong syntax.
>
> I've worked around like this:
>
> $allkeys = array_keys($_POST);
> $allvalues = array_values($_POST);
>
> for($I=3; $I < count($_POST); $I++) {
> echo $allkeys[$I];
> echo $allvalues[$I];
> }
>
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.
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
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.
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
And all you other answers around here:
http://nl.php.net/docs.php
and here
http://www.google.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php