bun 发表于 2011-07-25 17:50

xinglu1983 发表于 2011-07-25 18:29

你的规则描述的不清楚,functional-sophisticated-m66563这个会变吗?还是固定的,我先按最简单的理解的:
$str = "functional-sophisticated-m66563-p-723.html";
$str = preg_replace("/-p-*\.html/", "", $str);

bun 发表于 2011-07-26 02:18

maochanglu 发表于 2011-07-26 11:30

explode() - 使用一个字符串分割另一个字符串

xinglu1983 发表于 2011-07-26 11:50


$str = "functional-sophisticated-m66563-p-723.html";
test($str);
$str = "fdalfkdsaj-afidafodau-m123424-p-723.html";
test($str);
function test($str) {
    $str = preg_match("/(.*)(-p-*\.html)/", $str, $match);
    print_r($match);echo '<br />';
    print_r($match);echo '<br />';
}
页: [1]
查看完整版本: url截取