在PHP中,如何在特定单词后生成子字符串?
我有这样一个字符串: 标题2016年12月15日/0评论/主题/作者joe blow Facebook Twitter Google+LinkedIn我想展示的非常重要的内容。我不在乎标题和社交媒体词汇 我想去掉字符串以显示单词“LinkedIn”后的所有内容。您可以使用 输出在PHP中,如何在特定单词后生成子字符串?,php,wordpress,Php,Wordpress,我有这样一个字符串: 标题2016年12月15日/0评论/主题/作者joe blow Facebook Twitter Google+LinkedIn我想展示的非常重要的内容。我不在乎标题和社交媒体词汇 我想去掉字符串以显示单词“LinkedIn”后的所有内容。您可以使用 输出 My really important content that I want to display 您可以使用 输出 My really important content that I want to displa
My really important content that I want to display
您可以使用
输出
My really important content that I want to display
你可以用它来开始你想要的单词或字母的字符串
$str = "December 15, 2016/0 Comments/topic/by joe blow Facebook Twitter Google+ LinkedIn My really important content that I want to display";
$str= strstr($str, 'LinkedIn');
$str = trim($str,'LinkedIn');
echo $str;
你可以用它来开始你想要的单词或字母的字符串
$str = "December 15, 2016/0 Comments/topic/by joe blow Facebook Twitter Google+ LinkedIn My really important content that I want to display";
$str= strstr($str, 'LinkedIn');
$str = trim($str,'LinkedIn');
echo $str;
试试这个
$str = "Title December 15, 2016/0 Comments/topic/by joe blow Facebook Twitter Google+ LinkedIn My really important content that I want to display. I don't care about the title and social media words.";
$needle = "LinkedIn";
$pos = strpos ($str, $needle);
$substr = trim(substr($str,$pos + strlen($needle)));
试试这个
$str = "Title December 15, 2016/0 Comments/topic/by joe blow Facebook Twitter Google+ LinkedIn My really important content that I want to display. I don't care about the title and social media words.";
$needle = "LinkedIn";
$pos = strpos ($str, $needle);
$substr = trim(substr($str,$pos + strlen($needle)));
您可以使用
strop
、strlen
和substr
$str = "December 15, 2016/0 Comments/topic/by joe blow Facebook Twitter Google+ LinkedIn My really important content that I want to display";
$index = strpos($str, "LinkedIn"); // find from witch character "LinkedIn" starts
$index += strlen("LinkedIn"); // add "linked in length to $index"
$res = substr($str, $index); // separate that number of characters from your string
echo $res;
您可以使用
strop
、strlen
和substr
$str = "December 15, 2016/0 Comments/topic/by joe blow Facebook Twitter Google+ LinkedIn My really important content that I want to display";
$index = strpos($str, "LinkedIn"); // find from witch character "LinkedIn" starts
$index += strlen("LinkedIn"); // add "linked in length to $index"
$res = substr($str, $index); // separate that number of characters from your string
echo $res;
你能引用完整的字符串吗?在“linkedin”上使用字符串拆分吗?你能引用完整的字符串吗?在“linkedin”上使用字符串拆分吗?还请在语句后添加分号。;)在字符串开始处获得空格空格可以由phpOne中的trim()来处理空格,请为服从我而投票……)我主要是说swift和python,分号在我的大脑深处的某个地方,也请在语句后面加上分号在字符串开始处获得空格空格可以由phpOne中的trim()来处理空格,请为服从我而投票……)我主要是说swift和python,分号在我的大脑深处的某个地方将包括
LinkedIn
字符串的一部分现在它将删除LinkedIn:)1 voteup..下一步删除空白:)谢谢!字符串前面没有空格:)将包含LinkedIn
字符串的一部分现在它将删除LinkedIn:)1 voteup..下一步删除空格:)谢谢!空格不出现在字符串前面:)不错但很长。不错但很长。