I hope someone can help me resolve this issue. 😕

I have a string 12,000,000 and i am trying to convert it into integer. But when I typecast it truncates it to 12.

SO i am unable to compare to strings, because a value of 10,000 turnes out to be bigger than 9,000,000.

Any ideas?

THanks in advance!!!

🙂

    <?php
    function smart_intval($num) {
        $retval = strreplace(',','',$num);
        return intval($retval);
    } //end smart_intval
    ?>

      function smart_intval1($results['xxxxx'][0]) {
      $r1 = strreplace(',','',$results['xxxxx'][0]);
      return intval($r1);
      } //end smart_intval

      I replaced it with my values, but i get this error:

      Parse error: parse error, unexpected '[', expecting ')' in report.php on line 86

        line 86:

        function smart_intval1($results['xxxxx'][0]) {

          You need to call the function and pass $results['xxxxx'][0]

          like

          $result_val= smart_intval1($results['xxxxx'][0]) ;

          in the function you should have
          function smart_intval1($param_stringvariablename)
          {
          ....
          }

            Basically, drawmack's idea is to declare a function that replaces every comma in a given comma-grouped numeric string with a blank, effectively removing them.

            function smart_intval($num) {
            	return str_replace(',', '', $num);
            }

            then one would apply this function, e.g.

            $num = smart_intval($results['xxxxx'][0]);
              Write a Reply...