Welcome to W3Courses
 Like Us on Facebook

Foreach Function

Pass Array from Multipart/Form-data Post Method or Query String with Foreach Function in PHP

You can have your form build an array of mutiple text box values and then pass it. The problem is that is global variables are on, it will work but if global variables are off you will have to retrieve each element like the following. If you are using the query string, replace $_Post with $_Get

<?php

echo("<form name='multiupload' enctype='multipart/form-data' method='post' action='{$_SERVER['PHP_SELF']}'>");

Share

Loop through an Array using Foreach Function in PHP

You can loop through an array using foreach function. So instead of using:

<?php

$names = array("Paul","Maria","David","Lucy","Ana");

$i=0
while($names[$i] == true)
{
     echo("$names[$i]");
     $i++;
}

?>
 


You can be more efficient and use foreach:

<?php

Share