How to Find Number from String in PHP?
Hi,
Hello all! In this article, we will talk about how to find number from string in php. we will help you to give example of php get number from string. This article goes in detailed on php extract number from string. This article goes in detailed on php read number from string. So, let's follow few step to create example of php take number from string.
Here, i will give you simple example how to get number value from string content in php. so let's see both code and output as bellow:
Example:
index.php
<?php
$string = 'You have 500 Dollar and 13 Rupees';
preg_match_all('!\d+!', $string, $matches);
print_r($matches['0']);
Output:
Array
(
[0] => 500
[1] => 13
)
i hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to get HTML Tag Attribute Value in PHP?
- How to Get HTML Tag Value in PHP?
- PHP Calculate Time Difference Between Two Dates in Hours Example
- PHP Generate QR Code using Google Chart API Example
- PHP Array Get Previous Element from Current Key
- PHP Explode Every Character into Array Example
- PHP Remove Element from Array by Value Example
- PHP Curl Request with Username and Password Example
- PHP Check Word Exist in String or Not Example
- How to Convert Array Values to Lowercase in PHP?