How to Find int value from String in PHP?

Hi,

Hello all! In this post, we will talk about how to find number (int value) from string in php. we will help you to give example of php get number (int value) from string. This article goes in detailed on php extract number (int value) 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(int value) value from string content in php. so let’s see both code and output as bellow completely:

Example:

index.php

<?php 
  
    $strings = 'You have 1500 Apple and 15000 Rupees';
    preg_match_all('!\d+!', $strings, $json);
  
    print_r($json['0']); 

Output:

Array
(
    [0] => 1500
    [1] => 15000
)

i hope it can help you…

Leave a Comment