array and for clarification.

From: Brian ((_at_))
Date: 10/31/03


Date: Fri, 31 Oct 2003 06:13:51 GMT

I'm diddlying with a script, and found some behavior I don't understand.

Take this snippet:

for ($i = 0; $i <= count($m); $i++) {
    array_shift($m[$i]);
 reset($m);
}

This doesn't work, it says:
Warning: array_shift(): The argument should be an array in ./tool.php on
line 31

However, this does work:
$c = count($m);
for ($i = 0; $i <= $c; $i++) {
    array_shift($m[$i]);
}

Why can't I reference the count of $m in the for without it crapping out,
but if I make a variable it is fine? $m doesn't change, so even if it
recounted $m each time, it would be the same.. I'd think.

Many thanks.

--Brian



Relevant Pages

  • Re: Questions About Upgrading to dependency based boot
    ... script behind, package dovecot-common removed but not purged, package ... overrides, insserv: warning: script 'K01nxsensor' missing LSB tags ...
    (Debian-User)
  • "Malicious script" upon opening Help & Support center
    ... MaliciousScript detected ... Your computer is halted and needs to do something about this script ... As long as I don't press the OK button on the Norton warning, ... calling an HTA file to do its tasks. ...
    (microsoft.public.windowsxp.security_admin)
  • Re: "Malicious script" upon opening Help & Support center
    ... > to use help, do I choose "authorize this script" (which I interpret to mean, ... there appears a warning from Norton: ... >>> MaliciousScript detected ... >>> calling an HTA file to do its tasks. ...
    (microsoft.public.windowsxp.security_admin)
  • Re: Required Fields and Warning Boxes
    ... warning box to appear asking the user "are you sure you want to make ... field and shows the confirmation box but the information in the form ... Second Script: When I create a separate function with "are you sure ... Note that onSubmit wants a true or false value from the returning ...
    (comp.lang.javascript)
  • Re: [PHP] Hide Warnings
    ... warnings in the php script code? ... When you have an error in your script it shows potential bad ... sql statement please tamper with it). ... Maybe if you don't know how to fix the warning you received you ...
    (php.general)