I'm trying to get something to work but its just not happening Say i have "10 of about 14 from" in a string. I'm trying to use preg_match to get the value inbetween 'about' and 'from' so if it were to work it would return 14? Any ideas please
<?php $string = '10 of about 14 from'; if( !preg_match('~about ([0-9]+) from~si', $string, $match ) ) die("Invalid string passed"); echo $match[1]; ?> PHP:
Could anyone please tell me if it would be different if i had '10 of about 1,400 from' rather than '10 of about 14 from' and still using the same expression?
yeah above code only grab numeric character! if you want it to include the comma(s) in grabbing: <?php $string = '10 of about 1,400 from'; if( !preg_match('~about ([0-9,]+) from~si', $string, $match ) ) die("Invalid string passed"); echo $match[1]; ?> Code (markup):