You might want to consider mapping your JSON into a key/value array using array_column
; then it is easy to check for the existence of a value. For example:
$json_form = json_decode($json_string, true);
$values = array_column($json_form, 'value', 'name');
$user_title = $values['user_title'];
$user_firstname = $values['user_firstname'];
$user_lastname = $values['user_lastname'];
echo "title: $user_title
first name: $user_firstname
last name: $user_lastname
";
Output for your sample data is:
title: Bapak.
first name: Test
last name: XXX
It's also easy to add default values when a key is missing, for example:
$user_title = $values['user_title'] ?? '';
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…