Jump to content

what does this mean? +=


seany123

Recommended Posts

is anyone able to explain what this code is saying?

 

i had it written for me awhile back and now that i wanna change it about to make it my own etc i dont really know what each part is doing... esspecially the += part lol.

 

 

im using a form which includes this:

 

<input type="hidden" name="item_name" value="50 Awake Pills" />

 

and then from the form above this code is used:

 

$total = ereg_replace( "[^A-Za-z0-9]", "", $_REQUEST['item_name'] );

$total += 0;

for ( $i = 0; $i < $total; $i++ )

Link to comment
https://forums.phpfreaks.com/topic/180846-what-does-this-mean/
Share on other sites

*= $value 

is the same as $total = $total * $value.

 

.= $value

is the same as $total = $total . $value or even $total = "$total$value"

 

for ( $i = 0; $i < $total; $i++ )

 

is saying while $i is less than $total, loop, adding 1 to $i on each iteration ($i++ is the same as $i = $i + 1). It could also be written as

 

$i = 0;
while($i < $total) {
   $i++;
}

 

Faux Edit: But I recommend reading the links provided by salathe.

Link to comment
https://forums.phpfreaks.com/topic/180846-what-does-this-mean/#findComment-954074
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.