[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 419
  • Last Modified:

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
0
rgb192
Asked:
rgb192
1 Solution
 
mark_harris231Commented:
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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now