php - $_POST[] data at the top of page -


i'm having 20 $_post[] items @ top of page. there quicker way of writing these post data rather having retype $_post on , on again? (e.g.: may using foreach loop ?)

/*     $fname = $_post['fname']; $lname = $_post['lname']; $phone = $_post['phone']; $address = $_post['address']; */   $arr = array('fname', 'lname', 'phone', 'address');  foreach ( $_post $data => $val ) {  } 

the keys , variable names same. extract() -

extract($_post); 

will extract data in , assign variables named keys.

checks each key see whether has valid variable name. checks collisions existing variables in symbol table.

or if want use foreach -

foreach ( $_post $key => $val ) {     $$key = $val; } 

this assign value variable name key.

variable variables


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -