Kathmandu,Nepal
Kathmandu,Nepal

Remove character from string in php

Example:1

The following source code will remove character from string:

<?php  
$res = preg_replace("/[^0-9.]/", "", "$123.099");
echo $res;
?>

Output:
123.099

Example:2

<?php
$res = preg_replace("/[^0-9]/", "", "Every 6 Months" );
echo $res;
?>
Output: 
6

Leave a Comment

Your email address will not be published. Required fields are marked *

×