I am new to PHP. I have a simple API written in PHP which receives the data in JSON. I am converting the JSON into a PHP array and parsing it:
$obj = json_decode($json,true);
$demircap = $obj['demircap'];
$disuzun1 = $obj['disuzun1'];
$boy = $obj['boy'];
$demiradet = $obj['demiradet'];
I would like to define a new empty object ($disadet
) here and set a conditional state of the $demiradet
object. If it has a special String value, I would like to give my new object $disadet
as the double value of $demiradet
, such that if $disuzun1 == 'a'
, $disadet == $demiradet*2
.
This is my code:
if ($disuzun1 == 'a' || $disuzun1 == 'b' || $disuzun1 == 'c'){
$disadet == 2*$demiradet;
}else:
$disadet == $demiradet;
How can I do this conditional formatting with PHP?
Thanks.