I have an array which is a response from a post request and i would like to access both the key and value
This is the code
$arrs = json_decode(file_get_contents('php://input'), true);
foreach($arrs as $index=>$arr){
var_dump($arr["items"][ $index]);
//die() to see the first response
}
Now the above generates
array(1) {
[11]=>string(3) "dfd" //how do i get the 11 key
}
I would like to get 11 and "dfd" above so that i can then use them eg
$model->username = $arr["items"][ $index]//use dfd .. so my $model->username="dfd"
$model->like = $arr["items"][ $index]//use 11 .... so my $model->like =11