PHP Enumerate Parameter

Di seguito un esempio di come popolare una struttura dati, utilizzando i valori presenti nell’array $_POST

//Class for ArrayList
class Param {
	public $name;
	public $value;
}

//Popolate ArrayList
foreach ($_POST as $key => $value){
//   echo "{$key} = {$value}\r\n";
	$obj = new Param();
	$obj->name = $key;
	$obj->value = $value;
	
	$ArrayObjParam[] = $obj; //Append in array the object
}

//Print the ArrayList
for ($i = 0; $i < count($ArrayObjParam); $i++)
{
	echo '<br>'.$i . ' [' . $ArrayObjParam[$i]->name .'] ['. $ArrayObjParam[$i]->value .']';
}
This entry was posted in PHP, Programming Languages. Bookmark the permalink.