title: How to convert a string in a number PHP
body: <p>I have a Foreach where I have two variables ($num1 and $num2) as string. I'd like to covert them as number (integer should be ok).</p>
  
  <p>This is my code:</p>
  
  <pre><code>    ...
      foreach ($titles as $match) {
      list($num1, $num2) = explode(':', $results[$c++]-&gt;innertext); // &lt;- explode
  
      echo "&lt;tr&gt;&lt;td class='rtitle'&gt;".
      "&lt;td class='last-cell'&gt;".$match_dates[$c]-&gt;innertext . "&lt;/td&gt; " .
              //"&lt;td class='first-cell tl'&gt;".$match-&gt;innertext."&lt;/td&gt; "  .   
              " - ".$match-&gt;innertext." ".$num1.':'.$num2 .  "  "   .     
              "&lt;td class='odds'&gt;".$best_bets[$b++]-&gt;attr['data-odd'] . ";" .
              "".$odds[$b++]-&gt;attr['data-odd'] . ";" .
              "".$odds[$b++]-&gt;attr['data-odd'] . "&lt;/td&gt;" .
  
              "&lt;/td&gt;&lt;/tr&gt;&lt;br/&gt;";
  }
  ...
  </code></pre>
  
  <p>Thanks!</p>
  
  <p><strong>EDIT</strong><br>
  Thanks for your answer. I am going to explain and maybe you could help me: I have a a problem with <code>best_bets</code> value, because it's not alway before odds variable, so I was thinking to use "if statement", where I can fix some rules: when <code>$num1</code> is <code>&gt; $num2</code>, I will show an echo order; when  <code>$num1</code> is <code>= $num2</code> another echos order and. at least,  <code>$num1</code> is <code>&lt; $num2</code> another echos order. But to do this, I need to convert  $num1 and $num2 to do it. I hope to be clear. Thank you for your helping</p>