user3227899 user3227899 - 1 month ago 5x
PHP Question

Get specific value from variable in php

How do I get 100 from $price variable and set to other variable name? str_replace is best option or another?

$price="100-200 dollar";



i have variables "200-300 dollar", "1000-2000 dollar, "100-1000 dollar". i want get number before hyphen

And also want get number after hyphen symbol.(200-300 dollar->300, 1000-2000 dollar->2000 etc)

$price="100-200 dollar";



$pcs=explode(" ",$pieces[1]);


$val and $val2 are the values before hyphen and after hyphen respectively.