how to input JSON data with dynamic data array : person 1 input data with data array like this :

{"type":"1","name":"John", "phone":"898171"}

person 2 not set the phone, like this :

{"type":"1","name":"Lisa"}   // only write 2 array...



I have source code in my controller like this :

$data = json_decode(file_get_contents('php://input'), true);

if(!$data['phone']->iSEmpty){
   echo "you haven't set the phone number!"
}

but is not working.. error when second person input data.. "Undefined index: phone"

Sorry for my bad english btw...