Home » PHP29 April 2010

PHP: How to get integer or decimal from a string?

Suppose, I have a string with text and number and I only want the number. I don’t want the characters and text of the string.

Here is the way out:-

In this example, you will get only integer. It will omit all characters and text from the string.

This example prints decimal numbers removing all the characters from the string.

Hope this helps. Thanks.

PHP

Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed
  • Mian Waqas

    That’s what i was looking for. Thanks for such a nice code snippet.

  • Moe

    You are my hero… LoL
    This help me so much…
    Thank you for this code snippet…

  • David

    Thank you

  • Sandip Kc

    Got what I was searching for. Thank you.