Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#PHP, (削除) 40 (削除ここまで) 34 bytes

PHP, (削除) 40 (削除ここまで) 34 bytes

Along with $argv comes $argc ... and both are variable.
Either one of the arguments or +$argv[0]==+"-" is 0.

while(+$argv[--$argc])$i++;echo$i;

takes input from command line arguments. Empty output for 0.
Run with php -nr '<code>' <space separated values>

unary output, (削除) 35 (削除ここまで) 29 bytes

while(+$argv[--$argc])echo 1;

#PHP, (削除) 40 (削除ここまで) 34 bytes

Along with $argv comes $argc ... and both are variable.
Either one of the arguments or +$argv[0]==+"-" is 0.

while(+$argv[--$argc])$i++;echo$i;

takes input from command line arguments. Empty output for 0.
Run with php -nr '<code>' <space separated values>

unary output, (削除) 35 (削除ここまで) 29 bytes

while(+$argv[--$argc])echo 1;

PHP, (削除) 40 (削除ここまで) 34 bytes

Along with $argv comes $argc ... and both are variable.
Either one of the arguments or +$argv[0]==+"-" is 0.

while(+$argv[--$argc])$i++;echo$i;

takes input from command line arguments. Empty output for 0.
Run with php -nr '<code>' <space separated values>

unary output, (削除) 35 (削除ここまで) 29 bytes

while(+$argv[--$argc])echo 1;
+"-" is 0, which saves 6 bytes
Source Link
Titus
  • 14.9k
  • 1
  • 25
  • 41

#PHP, 40(削除) 40 (削除ここまで) 34 bytes

AlongsideAlong with $argv comes $argc ... and both are variable.
But I have to avoidEither one of the arguments or $argv[0]+$argv[0]==+"-" is (the script name)0.

forwhile(;+$argv[--$argc&&$argv[$argc];$i++$argc]);echo$i;$i++;echo$i;

takes input from command line arguments. Empty output for 0.

Run
Run with php -nr '<code>' <space separated values>

unary output, 35(削除) 35 (削除ここまで) 29 bytes

forwhile(;+$argv[--$argc&&$argv[$argc];$argc])echo 1;

#PHP, 40 bytes

Alongside with $argv comes $argc ... and both are variable.
But I have to avoid $argv[0] (the script name).

for(;--$argc&&$argv[$argc];$i++);echo$i;

takes input from command line arguments. Empty output for 0.

Run with php -nr '<code>' <space separated values>

unary output, 35 bytes

for(;--$argc&&$argv[$argc];)echo 1;

#PHP, (削除) 40 (削除ここまで) 34 bytes

Along with $argv comes $argc ... and both are variable.
Either one of the arguments or +$argv[0]==+"-" is 0.

while(+$argv[--$argc])$i++;echo$i;

takes input from command line arguments. Empty output for 0.
Run with php -nr '<code>' <space separated values>

unary output, (削除) 35 (削除ここまで) 29 bytes

while(+$argv[--$argc])echo 1;
added unary output
Source Link
Titus
  • 14.9k
  • 1
  • 25
  • 41

#PHP, 40 bytes

Alongside with $argv comes $argc ... and both are variable.
But I have to avoid $argv[0] (the script name).

for(;--$argc&&$argv[$argc];$i++);echo$i;

takes input from command line arguments. Empty output for 0.

Run with php -nr '<code>' <space separated values>

unary output, 35 bytes

for(;--$argc&&$argv[$argc];)echo 1;

#PHP, 40 bytes

Alongside with $argv comes $argc ... and both are variable.
But I have to avoid $argv[0] (the script name).

for(;--$argc&&$argv[$argc];$i++);echo$i;

takes input from command line arguments.

Run with php -nr '<code>' <space separated values>

#PHP, 40 bytes

Alongside with $argv comes $argc ... and both are variable.
But I have to avoid $argv[0] (the script name).

for(;--$argc&&$argv[$argc];$i++);echo$i;

takes input from command line arguments. Empty output for 0.

Run with php -nr '<code>' <space separated values>

unary output, 35 bytes

for(;--$argc&&$argv[$argc];)echo 1;
debug: need pre-decrement, not post-decrement to avoid `0`.
Source Link
Titus
  • 14.9k
  • 1
  • 25
  • 41
Loading
Source Link
Titus
  • 14.9k
  • 1
  • 25
  • 41
Loading

AltStyle によって変換されたページ (->オリジナル) /