- preg_match: documentation ( source)
- substr_compare: documentation ( source)
<?php
function endswith($string, $test) {
$strlen = strlen($string);
$testlen = strlen($test);
if ($testlen > $strlen) return false;
return substr_compare($string, $test, -$testlen) === 0;
}
if(false == endswith('http://localhost/events/10','/events/')){
echo 'true';
}
else{
echo 'false';
}
$testlen = strlen('/bob/');
if(false == (substr_compare('http://localhost/events/10','/events/',-$testlen)===0)){
echo 'true';
}
else{
echo 'false';
}
$url = 'http://localhost/events/10';
//$eventid = intval(strpos($url,'/events/').);
$matches = array();
preg_match ('(\d)+',$url,$matches);
foreach( $matches as $match){
echo $match;
}