Jump to content

Recommended Posts

I am opening a connection to a server to allow me to send a xml command which returns xml data to me, however when the connection is made I receive data from the server, once I send the xml command the returned xml data is appended to the original data from the server.

 

My question is can I clear the file of the connection data or ignore it totally or over-write it?

 

The code all works, it is just this extra data I want to remove.

 

This is my current code:

 

$xml_data ="<xml string to be sent to server goes here>";
$ras = fsockopen($svr_add,$svr_port,$errno,$errstr,$svr_timeout);

fputs ($ras, $xml_data);

$ras1 = stream_get_contents($ras, -1, -1);

fclose($ras);

$xml = $ras1;

echo print_r($xml);

Link to comment
https://forums.phpfreaks.com/topic/268545-empty-a-file-created-by-fsockopen/
Share on other sites

Ok... If I understand this correctly you're getting the connection string as part of the reply, and you want to remove this string from the data you get. What's stopping you from simply removing it (replacing with '') from the returned data, since you already know exactly what the connection string is? str_replace () should be all you need.

Is this a change that you control, as in do you send it to the server, or is it generated by the server outside of your control?

If the latter, then Regular Expressions or substr () should fix it. If the former, my previous statement is still true.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.