I've defined this function in php
function ifstatement($statement = 'if(10 > 9;1+1;2+2)') {
// $statement = str_replace(' ', '', $statement);
if (strpos($statement, 'if(') > -1) {
$statement = rtrim(ltrim(str_replace(' ', '', $statement), 'if('), ')');
$exp = explode(';', $statement);
if ( $exp[0] ) {
if (strpos($exp[1], 'if(' )> -1) {
return ifstatement($exp[1]);
} else {
return 1;
}
} else {
if (strpos($exp[2], 'if(')> -1) {
return ifstatement($exp[2]);
} else {
return 0;
}
}
}else{
echo 'out';
}
}
the problem is the function always return 1 even if the condition in the if statement in the function argument is false which is tested with
if($exp[0])
it looks like the $exp[0] comes as a string, how can i convent this to be tested as if argument

