I’m trying to get the first element of my asociative array $_POST['tableFields']
.
print_r($_POST['tableFields']); // I get: ["id","usuario","apellido1","apellido2","email","password"]
I tryied using reset()
method but doesn’t show anything.
$campo = reset($_POST['tableFields']); print_r($campo); // This doesn't show anything.
Advertisement
Answer
It is JSON format so its a string value. You must do print_r(json_decode($_POST['tableFields'],1)[0]);
or reset(json_decode($_POST['tableFields'],1));