If condition i JSON?
Hej,Jeg har prøvet at lave en If condition i en JSON code men den går direkte til else, uanset at jeg i min form skriver Norwegian i z_subject - nogle som kan se hvad der er i vejen?
if (z_subject === "Norwegian") {
foreach($_POST as $key => $value){
if(preg_match('/^z_/i',$key)){
$arr[strip_tags($key)] = strip_tags($value);
}
}
$create = json_encode(array('ticket' => array(
'subject' => $arr['z_subject'],
'comment' => array( "value"=> $arr['z_what'] . "\n" . $arr['z_description']),
'requester' => array('name' => $arr['z_name1'] . " " . $arr['z_name2'],
'email' => $arr['z_requester']),
'custom_fields' => array(
array(
'id' => 25576682,
'value' => $arr['z_booking_norwegian']
),
array(
'id' => 25576822,
'value' => $arr['z_subject']
),
array(
'id' => 25556411,
'value' => $arr['z_adresse_klient']
)
)
)
));
} else {
foreach($_POST as $key => $value){
if(preg_match('/^z_/i',$key)){
$arr[strip_tags($key)] = strip_tags($value);
}
}
$create = json_encode(array('ticket' => array(
'subject' => $arr['z_subject'],
'comment' => array( "value"=> $arr['z_what'] . "\n" . $arr['z_description']),
'requester' => array('name' => $arr['z_name1'] . " " . $arr['z_name2'],
'email' => $arr['z_requester']),
'custom_fields' => array(
array(
'id' => 25576682,
'value' => $arr['z_booking']
),
array(
'id' => 25576822,
'value' => $arr['z_subject']
),
array(
'id' => 25555971,
'value' => $arr['z_departure_airport']
),
array(
'id' => 25556411,
'value' => $arr['z_adresse_klient']
)
)
)
));
}