A preg_replace(), , , , . konforce - URL-, URL-, , .
$guid = 'http://www.test.com/?p=34';
$guid2 = preg_replace("/^.*[&?;]p=(\d+).*$/", "$1", $guid);
Note that if a variable cannot be specified in the URLs p=<number>, then you will need to use match instead, since preg_replace () will not match and will return the entire string.
$guid = 'http://www.test.com/?p=34';
$matches = array();
if (preg_match("/^.*[&?;]p=(\d+).*$/", $guid, $matches)) {
$guid2 = $matches[1];
} else {
$guid2 = false;
}
source
share