Jump to content

So stupid


Blu23

Recommended Posts

Okay so I've been going over the PHP manual doing test applications as I go along and I came across this issue that honestly totally threw me. I figured it out (after 20 minutes of thinking the world was about to end) so thought I'd post the code and although some experts will simply shake their head others will hopefully see the funny side.

 

So I'm running a simple script iterating through two arrays and outputting some text. Code is below.

 

<?php
for($i = 0;$i < 100;$i++){

	for($k =0; $k < 100;$k++){
		echo "$i and $k";
	}
}
?>

 

I'd have expect to get something along the lines of 00 and 01 and 02 and 03 etc... but as you have probably guessed that's not what I was getting. Instead I was getting 0 and 00 and 10 and 20 and 30.

 

Anyway figured it all out now and I'm hanging my head in shame.

Link to comment
https://forums.phpfreaks.com/topic/233291-so-stupid/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.