-1

以下の for ループ内のコードの各行が何を意味するのか、または何をするのか、誰か説明してもらえますか?

$var = array();
$ship = $_POST['product'];
$amount = count( $ship );

for ($i = 0; $i < $amount; $i++){


$var[$i]['product']

$ship[$i]

$var[$i]['name'] = $ship[$i];

echo $var;


}

ありがとうございました!

4

1 に答える 1

4

面白いからといって:

$var = array(); // create an array
$ship = $_POST['product']; //store 'product' from HTTP POST in .. what, ship?
$amount = count($ship); //it seems our ship as an array, let's figure out how much items it contains
for ($i = 0; $i < $amount; $i++) //let's start from element #0, and do it until all ship's elements will be passed
{ // opening bracket
  $var[$i]['product']; //do nothing? ; was skipped
  $ship[$i]; //do nothing? ; was skipped
  $var[$i]['name'] = $ship[$i]; //store whole 'ship' in 'name' index of 'var'
  echo $var; //tada: echoing var
} // closing bracket
于 2013-08-15T10:43:47.017 に答える