note 61809 added to function.sizeof
| From: | blasterncs at hotmail dot com | Date: | Sun, 12 Feb 2006 19:41:47 +0000 |
| Subject: | note 61809 added to function.sizeof | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-103578@lists.php.net to get a copy of this message | ||
In some cases you can use this.
<FORM ACTION="receiver.php" METHOD=POST>
<INPUT TYPE=CHECKBOX NAME="arreglo[]" value="1">Thing #1
<INPUT TYPE=CHECKBOX NAME="arreglo[]" value="2">Thing #2
<INPUT TYPE=CHECKBOX NAME="arreglo[]" value="3">Thing #1
<INPUT TYPE=CHECKBOX NAME="arreglo[]" value="4">Thing #4
<INPUT TYPE=SUBMIT>
</FORM>
In the case you mark two (1 & 3) you will have that result:
sizeof($_POST[arreglo]) -> 2
the different is that you can use:
for($i=0; $i<sizeof($_POST[arreglo]); $i++)
Because the array is like that:
$_POST[arreglo]=array( '0'=> '1', '1' => '3');
Another thing.
If you have an array with null values, use this:
count(array_keys($array));
----
Server IP: 130.206.1.5
Probable Submitter: 84.77.100.3
----
Manual Page -- http://www.php.net/manual/en/function.sizeof.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+61809
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61809&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61809&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61809&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61809&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61809&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61809&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61809&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+61809&report=yes
Search -- http://master.php.net/manage/user-notes.php