PHP Enumerate Parameter

June 20, 2020 4:23 pm Published by

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 .']';
}

Categorised in: ,

This post was written by admin

Comments are closed here.