regex or str replace

I am using php
want to use regex or maybe str_replace


Text: "Business & Industrial > Heavy Machinery > Chippers"
 
XML: Business & Industrial > Heavy Machinery > Chippers


given
"Business & Industrial > Heavy Machinery > Chippers"
 
want this as output
Business & Industrial > Heavy Machinery > Chippers
LVL 1
rgb192Asked:
Who is Participating?
 
mark_harris231Connect With a Mentor Commented:
This should work.  Obviously, substitute your specific variables.

$str     = "Business & Industrial > Heavy Machinery > Chippers";
$order   = array("&",">");
$replace = array("&",">");

$newstr = str_replace($order, $replace, $str);

Note: the sequence of the $order and $replace arrays is important.  If you reverse the "&" and ">" replacement pairs, you would end up with the following (undesired) result:

Business & Industrial > Heavy Machinery > Chippers
0
 
rgb192Author Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.