php教程 正则指定区别内容
*/
$str ="{dede:link text='三版下载'} http://softs.111cn.net/5j/game/2011/03/04/hs60v3.sisx {/dede:link}
";
$link = array_filter(explode('{/dede:link}',$str ),"filter");
$len = count( $link );for( $i=0;$i< $len-1;$i++ )
{
$tpattern="/{dede:link text='(.*)'}/i";
$ppattern="/'}(.*)/i";
preg_match_all($tpattern,$link[$i],$title);
preg_match_all($ppattern,$link[$i],$path);
echo '<a href='.$path[1][0].' >'.$title[1][0].'</a> ';
}function filter($var)
{
if($var == '' || $var ==' ')
{
return false;
}
return true;
}
时间: 2024-10-24 15:09:16