PHP functions will not work with the String object, but works with it typed manually


I'm trying to strip tags from a text output coming from an object. The problem is, that I can't. If I type it manually like "<p></p>", it works fine! When doing echo $item->text; it gives me the same string "<p></p>"; Doing var_dump or even gettype, gives me a string(). So, I'm sure its a string, but it's not acting like it, I tried several functions preg_replace, preg_match, strip_Tags, none worked. How can I solve this situation, how to debug it ?

 $search = array("<p>", "</p>");
 $switch = array("foo", "baa");

 //works just fine, when used
 $text = "<p></p>"; 

 //it's a string for sure!

 $text = $item->introtext;

 //doesn't work
 $text = str_replace($search, $switch, $text);

 $text = strip_tags($text, "<p>");

 //doesn't work either.
 $matches = array();
 $pattern = '/<p>(.*)<\/p>/';

 preg_match($pattern, $text, $matches);

 //gives me the following output: <p></p>
 echo $text;

Try the following

$text = $item->introtext;
$newText = strip_tags($text);