gpt4 book ai didi

php - 从PHP中的字符串中删除一部分字符串

转载 作者:行者123 更新时间:2023-12-04 22:18:35 26 4
gpt4 key购买 nike

我做了一些工作,从 Google API 搜索结果片段中获取字符串。在此字符串中包含 <b></b>这给进一步的工作带来了问题,所以我需要删除 <b></b>

主要字符串代码:

$content_all .="#$*@#" . $json->responseData->results[$x]->content;

在我尝试使用此代码删除 <b> 之后和 </b> :

 $content_all=(string)$content_all;
str_replace("<b>", " ", $content_all);
str_replace("</b>", " ", $content_all);

但它不会删除 <b></b> . 我试过了

str_replace("hello", " ", "Hello people");

成功了。但为什么它不适用于 $content_all刺。我写了 $content_all 的值,它看起来像这样

#$*@#These <b>sad songs</b> will definitely make you shed tears...unless you&#39;re a robot.#$*@#Check out our top 35 <b>songs</b> about heartbreak. Did we miss any? Let us know!#$*@#Feb 10, 2014 <b>...</b> &quot;Somewhere Somehow&quot; available on iTunes now! http://smarturl.it/somewhere-
somehow Music video by We The Kings performing <b>Sad Song</b> ...#$*@#Nov 12, 2015 <b>...</b> There&#39;s nothing like a <b>sad</b>, slow <b>song</b> to aid in a postbreakup cry or to be the
soundtrack to a bad day. It&#39;s a well-known fact that music is made ...#$*@#May 12, 2015 <b>...</b> Yes, <b>sad songs</b> do say so much. And these 50 songs helped the Paste staff to
hurt so good. I tried to keep it to one song per artist but Johnny ...#$*@#Just Cry, <b>Sad Songs</b>. Indiemono. The saddest and original playlist on Spotify, &#39;
Just Cry, <b>Sad Songs</b>&#39;, it&#39;s been active for 3 years, time of ... Song, Artist, Album ...#$*@#<b>sad songs</b>, <b>sad song</b>, saddest song in the world, world´s saddest song, battle
song, sadsong, love song.#$*@#Last month we made a playlist of the 50 most uplifting songs ever. Now, we look
at the opposite: 50 beautifully <b>sad songs</b>, beginning with Amy Winehouse ...#$*@#Are you looking for the best <b>sad songs</b>? Look no further, this post contains our
favorite 20 <b>sad songs</b> of all time (as of 2015)!#$*@#8tracks radio. Online, everywhere. - stream 2500+ <b>sad songs</b> playlists including
sad, Coldplay, and indie music from your desktop or mobile device.#$*@#Nov 6, 2015 <b>...</b> We will also be engaging in the ritual of indulging our completely unnecessary,
sun-affected sadness by playing sad, <b>sad songs</b> on infinite ...#$*@#&quot;<b>Sad Songs</b> (Say So Much)&quot; is a song by Elton John and is the closing track on
the 1984 album Breaking Hearts. It reached the No 5 on the U.S. chart. The lyrics
 ...#$*@#<b>Sad Songs</b> for Dirty Lovers is the second studio album by indie rock band The
National. It was released in 2003 on Brassland Records. This is the first album on
 ...#$*@#Sep 24, 2015 <b>...</b> The popular belief that a <b>song</b> can be so <b>sad</b> that it can trigger suicide has a long
history. Written in 1933 by Hungarian composer Seress and ...#$*@#The National - <b>Sad Songs</b> for Dirty Lovers - Amazon.com Music.#$*@#<b>Sad Songs</b> 1 Songs download Free Music Latest New Top Best Hit Play Trend
Albums Single djjohal com 20 online dj remix.

最佳答案

如果你想从字符串中删除 html 标签,你可以使用 strip_tags()

例如:

   <?php
echo strip_tags("Hello <b>world!</b>");//Hello world
?>

小心 strip_tag 将从字符串中删除所有标签。

引用http://www.w3schools.com/php/func_string_strip_tags.asp .

如果你使用 str_replace("<b>", " ", $content_all); 还有一件事然后它会给出不需要的空间

ie:str_replace("<b>", " ", "hi <br><br> vig");
result: hi vig

关于php - 从PHP中的字符串中删除一部分字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34318232/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com