Jump to content

Logic behind foreach ($_POST as $key => $value)


akshay

Recommended Posts

an array is always consists of key value pair e.g

 

$numericArray = array(1=>'apple',2=>'orange');

or

$associativeArray = array('shoe'=>'abc','cloaths'=>'xyz')

 

when we loop throw both then

 

in $numericArray $key will be 1,2 and values will be apple and orange

and in $associativArray $key will be shoe, cloaths and values will be abc and xyz

 

you can do so

 

foreach($anyArray as $key=>$value){

  echo  $key . ' = ' . $value;

}

 

Link to comment
Share on other sites

  • 4 years later...

How could you perform some action on the original value of $value before reaching the $key => $value stage?

?

foreach ($_POST as $key => $value) 

 

Comes from    <input type="text" class="required" name="nombre" />

 

Need to convert the original value of $value to proper case. It is now being entered helter shelter lowe, mixd, all caps, etc.

Link to comment
Share on other sites

Guest
This topic is now 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.