calmchess Posted January 19, 2010 Share Posted January 19, 2010 could sombody plz read this code to me i know what it does as a whole but each indvidual part is a mystry especilly .= foreach ($_POST as $key => $value){ $postvals .= $key . " : " .$value .":"; } Quote Link to comment https://forums.phpfreaks.com/topic/189064-plz-read-this-code-to-me/ Share on other sites More sharing options...
o3d Posted January 19, 2010 Share Posted January 19, 2010 $_POST is an indexed and associative array (whichever way you want to use it). The foreach command basically loops through all items (on the same level). In each iteration the associative name will be placed in $key and the value for $key will be placed in $value. e.g. 'NAME'=>'John Doa' $key = 'Name' and $value = 'John Doa' Then for each iteration the 'variable' name and value will be appended with $postvals seperated by a colon. Hope that helps? Quote Link to comment https://forums.phpfreaks.com/topic/189064-plz-read-this-code-to-me/#findComment-998232 Share on other sites More sharing options...
Matt79 Posted January 19, 2010 Share Posted January 19, 2010 I believe the .= means that you are taking what is already in $postvals and adding $key to it. Similar to setting a variable but adding to it instead of completely redoing it. Example: <?php $postvals="Hello"; $key="world"; $postvals.=$key; echo $postvals; // should output Helloworld ?> Quote Link to comment https://forums.phpfreaks.com/topic/189064-plz-read-this-code-to-me/#findComment-998233 Share on other sites More sharing options...
KevinM1 Posted January 19, 2010 Share Posted January 19, 2010 . is the string concatenation operator. .= is a shorthand operator. The following statements are equivalent: $var1 = $var1 . " and something added at the end."; $var1 .= " and something added at the end."; Quote Link to comment https://forums.phpfreaks.com/topic/189064-plz-read-this-code-to-me/#findComment-998243 Share on other sites More sharing options...
calmchess Posted January 19, 2010 Author Share Posted January 19, 2010 thanks Quote Link to comment https://forums.phpfreaks.com/topic/189064-plz-read-this-code-to-me/#findComment-998251 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.