how i can turn in PHP the $validation output from 1/0 to the word "valid/invalid"? Do i need json_encode($validation) in this case?
$json = json_decode($content, true);
if ($json['error'] == NULL ) {
$country = $json['result']['countryCode'];
$vatNumber = $json['result']['vatNumber'];
$validation = $json['result']['valid'];
echo "
<dt>Valid:</dt>
<dd>$validation</dd>
<dt>VAT-Number:</dt>
<dd>$country$vatNumber</dd>
} else {
echo "error";
}
Thank you!
simple as 1 == true and 0 == false
if($validation === 1){
$validation = 'valid';
} else {
$validation = 'invalid';
}
have a reading of the php docs on boolean
how about this:
...
<dd>" . ($validation ? 'valid' : 'invalid') . "</dd>
...
or with a secondary check
...
<dd>" . ($validation == 1 ? 'valid' : 'invalid') . "</dd>
...
You could use an array:-
$validOrNot = ['invalid', 'valid'];
//some other code 'n stuff
$validation = $validOrNot[$json['result']['valid']];