Jump to content

[SOLVED] Parse number from url?


ballhogjoni

Recommended Posts

The end of test-test?  Will it always be test-test, or is that just an "example" query string that actually looks nothing like the real one? >_>  If so, please show us the real string you're trying to parse so we can help better.  Otherwise:

 

<?php
$str = "http://xxxxxx.com/test-test1.html";
$matches = array();
preg_match('~(test-test)([0-9]+?)\.html$~i', $str, $matches);
echo $matches[2];
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.