我试图在破折号之前从我的标题返回所有内容,这是我的代码
$mystring = "Nymphomaniac: Volume 1 – Nimfomana Vol. I (2013) – filme online";
$mystring = str_replace(' ', '+', $mystring);
$mystring = str_replace('-', '(/', $mystring);
$parts1 = explode("(", $mystring);
//break the string up around the "(" character in $mystring
$mystrings = $parts1[0];
echo $mystrings;
输出是这个
Output:
Nymphomaniac:+Volume+1+–+Nimfomana+Vol.+I+
我想要的是这个
Output:
Nymphomaniac:+Volume+1
我认为问题在于有2个破折号我已经尝试了所有但是没有工作,谢谢你的帮助
答案 0 :(得分:0)
试试这个。
<?php
$mystring = "Nymphomaniac: Volume 1 – Nimfomana Vol. I (2013) – filme online";
$array = explode("–", $mystring);
$string = str_replace(" ", "+", trim($array[0]));
echo $string; //Prints Nymphomaniac:+Volume+1
?>