开发者

Remove Specific Information from a String - PHP

开发者 https://www.devze.com 2023-04-08 17:39 出处:网络
I\'m working on a php script for work, I\'ve got most o开发者_运维问答f it figured out and spent hours,

I'm working on a php script for work, I've got most o开发者_运维问答f it figured out and spent hours, trying to get this working. Here's the deal. I've got this information.

</i>xxxx at \<a href=\"http://xxx/xxx/xxxx/11205xxx3887\" data-hovercard=\"/ajax/xxxx/xxx.php?id=112054175xxx3887\">xxxxx\</a>\</span>\

Ofcourse i'm trying to format this to be readable, something like,

xxxx at xxxxx

problem is the url changes constantly or i could just use a easy substr or something.

Any suggestions???


Use the the following:

$str = strip_tags($str);

See php.net/strip_tags


Here is my best attempt. It would be helpful if you could provide a larger section of code to work with, and if you could explain what the xxxx stands for it would make it much easier to solve your problem. Are they characters, numbers, times, prices? And do you know the origin of all the kooky forward slashes? Very unsettling...

I used the code as it was provided, so you may want to watch out for the last trailing \. When I copied your code into my text editor it pasted as \n rather than \.

$string = "</i>xxxx at \<a href=\"http://xxx/xxx/xxxx/11205xxx3887\" data-hovercard=\"/ajax/xxxx/xxx.php?id=112054175xxx3887\">xxxxx\</a>\</span>\\";

$modified_string = trim(stripslashes(strip_tags($string)), '\\');

echo $modified_string;
0

精彩评论

暂无评论...
验证码 换一张
取 消