Character strange html [duplicate] - php

This question already has answers here:
How do I remove ASCII number 13?
(1 answer)
PHP remove line break or CR LF with no success
(9 answers)
How to remove ANSI-Code ("
") from string in PHP
(4 answers)
Closed 4 years ago.
Ok, maybe is simple question but i am generating a xml from custom posts of wordpress, the problem is a textarea field of acf, i put a break line here and the code generate give me this character 
 but i not find nothing about that in google and str_replace not make nothing about that. i already remove the <br /> and <br> but that character I can't.
this is my actual code about that
str_replace('
', '', str_replace('<br />', '', strip_tags($addressValue['c_restaurant_map_address'], '<br /><br/><br>')));

Related

How to prevent PHP from renaming '&times' to 'x' symbol? [duplicate]

This question already has answers here:
Why is "&reg" being rendered as "®" without the bounding semicolon
(8 answers)
Should an ampersand be URL encoded in a query string?
(2 answers)
Closed 2 years ago.
I have with an unwanted replaced, and not able to figure out how to fix it.
When you echo the following string in PHP
echo('?hash=123&rid=111&timestamp=123');
The output is:
?hash=123&rid=111×tamp=123
Note that &timestamp has been replaced with ×tamp
I tried to escape it by using \&timestamp but that doens't work.
How can I prevent PHP replacing this?
You can reproduce this error online using http://phptester.net/
You have to escape that string, because & is a special symbol in HTML.
echo htmlspecialchars('?hash=123&rid=111&timestamp=123');
More information on the PHP site: https://www.php.net/manual/en/function.htmlspecialchars.php

remove white space before after of data in text area [duplicate]

This question already has answers here:
How do I strip all spaces out of a string in PHP? [duplicate]
(4 answers)
Closed 5 years ago.
I input string to textarea such as below:
email1#gmail.com
email#gmail.com
email3#gmail.com
email4#gmail.com
How to format they to:
email1#gmail.com
email#gmail.com
email3#gmail.com
email4#gmail.com
One email in one line in textarea. I want use PHP to make it.
Please help me about solution, thanks you.
this should work in php
str_replace(' ','',$yourText)
If you want to remove all whitespace:
$str = preg_replace('/\s+/', '', $yourstring);
Use the trim function to do this.
return(trim($str));

How to find a character using index in PHP string? [duplicate]

This question already has answers here:
Finding a character at a specific position of a string
(5 answers)
Closed 5 years ago.
I have a string in PHP code like this:
$string = "This is a PHP code";
I want to find a character at index 3 in above string. And output must be:
s
Is there any idea to achieve this goal ?
If I understood your question properly, you want character at 3rd index then write following line ;)
echo $string[3];

remove plaintext links from post in php [duplicate]

This question already has answers here:
Regular expression for checking website url
(6 answers)
Match URL pattern in PHP using a regular expression
(8 answers)
Closed 6 years ago.
The question is fairly straight forward. I want to remove text links from posts.
$post = $_POST['text'];
//something to remove any instance of a text link
Please understand I am not trying to remove
text
Rather I just want any plaintext links removed
This is an example. All this is okay but I want the following stripped:
http://someurl.com/... or http://www.someurl.com/...
Here is what I have been trying:
$post = preg_replace(#^(http\:\/\/|https\:\/\/)?([a-z0-9][a-z0-9\-]*\.)+[a-z0-9][a-z0-9\-]*$#i, '', $posted);
I am getting error: unexpected '^', if I remove the ^ then I get an unexpected ':' error.

How to remove white space in PHP generate css class? [duplicate]

This question already has answers here:
How do I strip all spaces out of a string in PHP? [duplicate]
(4 answers)
Closed 6 years ago.
I would like to remove white space in a php generated css code, I have different title header which would like to generate through php code.
Titles are like 1) Baby Day Care 2) Baby Night Care
My php codes are like:
<div class="wistia<?php echo $subject->title;?>">
So when I got the class, I got like wistiaBaby Day Care or wistiaBaby Night Care
But I want the class will be look like wistiaBabyDayCare or wistiaBabyNightCare
(I want space removed between text).
So how I am going to achieve that?
That should to the trick:
<div class="wistia<?php echo str_replace(' ', '', $subject->title);?>">
This just uses the str_replace function where you replace the first character with the 2nd character for a given string.
To remove any whitespace simply use preg_replace (regex):
<div class="wistia<?php echo preg_replace('/\s+/', '', $subject->title);?>">

Categories