I had a php script to run the if else to replace the value based on condition:
//$mobile = '23456701';
$mobile = '01234567';
$zero_lead = "/^01/";
$country_code = "44";
$phone = preg_replace($zero_lead, $country_code, $mobile);
if (strpos($phone, '/^0/') !== true) {
$accountNumber = $mobile;
}
else
{
$accountNumber = '';
}
$post_data = array(
'phone' => $phone,
'accountNumber' => $accountNumber,
);
echo json_encode($post_data);
return: {"phone":"44234567","accountNumber":"01234567"}
my expected return if $mobile = '01234567';
will return {"phone":"44234567","accountNumber":""}
and $mobile = '23456701';
will return {"phone":"23456701","accountNumber":"23456701"}
any one have suggestion?
Thanks
Aucun commentaire:
Enregistrer un commentaire