Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Me1000

macrumors 68000
Original poster
Jul 15, 2006
1,794
4
I'm not really sure what my problem is. the code is similar to as follows

(please note several lines were removed for this post (hence the "..."s) :)

Code:
$item['DESCRIPTION'] = 'More Newandnbsp;Photos fromandnbsp;New';
function addItemToDB($item){
...
$description = $item['DESCRIPTION']; 
	
$description = str_replace('andnbsp;', ' ', $description);
$description = mysql_escape_string(preg_replace('/<[^>]*>/', '', $description)); //parse out the html tags
...
}

When I call the function though, this is outputted for the $description:
More Newandnbsp;Photos fromandnbsp;New

in other words, It's not working!

Is there something I'm missing?


:apple:
 
PHP:
<?php
$a = "More Newandnbsp;Photos fromandnbsp;New\n";
echo "<p>$a</p>";
$a = str_replace('andnbsp;', ' ', $a);
echo "<p>$a</p>";
?>
Output:
Code:
More Newandnbsp;Photos fromandnbsp;New

More New Photos from New
Works for me. So, nothing is wrong with the code you're showing. Maybe a typo somewhere else. I'd suggest some debugging by echoing some variables in other locations and also checking your PHP error log.
 
Debugging by echoing the vars might be a little difficult given the complexities of the script.

Before I start commenting out a bunch of stuff to do that...

The string I'm pulling in is not from my own server, so I have very little control over the format of the string. Could the problem be the type of characters it is? (a la unicode, etc...)?
:apple:
 
The string I'm pulling in is not from my own server, so I have very little control over the format of the string. Could the problem be the type of characters it is? (a la unicode, etc...)?
:apple:

I don't believe that should be a problem.
 
Wow, I'm an idiot.

The data I'm working with is so clunked up that I was running the replace on the wrong data set. XD
:rolleyes:


Thank you for your help!

:apple:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.