title: How to convert string to boolean in php
body: <p>I've defined this function in php </p>
  
  <pre><code>function ifstatement($statement = 'if(10 &gt; 9;1+1;2+2)') {
  // $statement = str_replace(' ', '', $statement);
  
  if (strpos($statement, 'if(') &gt; -1) {
     $statement = rtrim(ltrim(str_replace(' ', '', $statement), 'if('), ')');
     $exp = explode(';', $statement);
    if ( $exp[0] ) {
      if (strpos($exp[1], 'if(' )&gt; -1) {
       return ifstatement($exp[1]);
      } else {
       return 1;
     }
    } else {
    if (strpos($exp[2], 'if(')&gt; -1) {
      return ifstatement($exp[2]);
    } else {
     return 0;
    }
   }
  }else{
    echo 'out';
    }
  }
  </code></pre>
  
  <p>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 </p>
  
  <pre><code>if($exp[0])
  </code></pre>
  
  <p>it looks like the <code>$exp[0]</code> comes as a string, how can i convent this to be tested as if argument</p>