0

I have a list on the page. And I want to get only amount (to be more specific, only total sum). So I tryed ot do it via post an array which i transform and i get rows like:

"recived from player"

"0.000058"

"2014-06-30 15:21:46 UTC"

I have tryied to get an if(is_numeric($row1)) but it doesn't work (blank page).

    foreach ($p as $r) {
    $row = str_replace("\t",'<br />',$r);
            $row1 = str_replace("silver","",$row);
        if (is_numeric($row1)) {
            echo $row1;
        }
}

Any idea how to solve it?

4
  • 3
    can you put a print_r of $p please --> <pre> <?php print_r($p); ?> </pre> Commented Jul 1, 2014 at 9:48
  • <?php var_dump($_POST) ?> and see what you get Commented Jul 1, 2014 at 9:52
  • floatval($row1) should do the trick, but I'm not understanding your variable names which is where I'm guessing your problem is Commented Jul 1, 2014 at 9:53
  • @Su4p print_r($p) output: Array ( [0] => received from libby 0.00000300 silver 2014-07-01 9:53:38 UTC received from leow 0.00000050 silver 2014-07-01 9:53:25 UTC ) 1 Commented Jul 1, 2014 at 10:14

1 Answer 1

1

It will be better to split string to array and then check for Number.

      $wordChunks = explode(" ", $someWords);  

      for($i = 0; $i < count($wordChunks); $i++)
           {
                if (is_numeric($wordChunks[$i])) 
                      {
                        echo $wordChunks[$i];
                      }

           }
Sign up to request clarification or add additional context in comments.

1 Comment

And this is a best! Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.