Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8904857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:14:40+00:00 2026-06-15T02:14:40+00:00

I am getting an xml file from a webservice. Unfortunately the file contains character

  • 0

I am getting an xml file from a webservice.

Unfortunately the file contains character code 2 (\u0002), which breaks the parser.

So I’m trying to remove all character code 2’s, but I get wierd results just when trying to do a simple string replace.

To test this, I created a php file named test.php with the following content:

<?
$aaa="Hi"+chr(2)+"There"+chr(2)+"Rick";
$aaa = str_replace($aaa,chr(2),"");
echo $aaa;
?>

I’m running this from the command line:

php test.php

When I run this I get a blank string.

What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:14:42+00:00Added an answer on June 15, 2026 at 2:14 am

    Yes your result would be black because PHP uses . for concatenation and not +

    You should change

    $aaa="Hi"+chr(2)+"There"+chr(2)+"Rick";
    

    To

    $aaa="Hi".chr(2)."There".chr(2)."Rick";
    

    Also also from PHP DOC

     mixed str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )
    

    You should also change

    $aaa = str_replace($aaa,chr(2),"");
    

    To

    $aaa = str_replace(chr(2),"",$aaa);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an application in which I am getting a XML file from
am trying to get the XML file from a URL but am getting no
I'm trying to manipulate a xml file from sharepoint document library with powershell. Unfortunately
I have get an xml file from a WebService <MasterProducts> <MasterProduct> <Productcode>023DDC</Productcode> <Description>Dell CRT
I've posted an excerpt from my spring.xml file and the stack trace I'm getting.
I'm having trouble getting the XML from a file using the simplexml_load_file function. I
I'm supposed to be getting XML output from the following php file that is
I'm trying to read a xml file (from facebook) into my page. I keep
in my app i am trying to get an xml file from an URL.
Ok, I'm trying to get a file from my webserver. But I'm getting kinda

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.