PHP字符串拆分

时间:2013-03-15 09:52:44

标签: php string

$var=<a href="/abcd/100th-indian-science-congress">100th Indian Science Congress</a>;

在上面我只是想连接“ 100th-indian-science-congress ”所以请帮我解决这类问题

3 个答案:

答案 0 :(得分:2)

$result = str_replace(" ", "-", $var);

答案 1 :(得分:0)

preg_match ('/a href="(.*?)"/', $var, $matches);

结果应该是$ matches [1];

答案 2 :(得分:0)

<?php
  $var= '<a href="/abcd/100th-indian-science-congress">100th Indian Science Congress</a>';  

  $url = preg_match('/<a href="(.+)">/', $var, $match);
  $outcome = basename($match[1]);
?>

结果见: http://sandbox.onlinephpfunctions.com/code/b4eea464a27c02d97e7bdd42fa959ff12884de96