Need Help cant remove certain feilds from files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
evin1207
Forum Newbie
Posts: 6
Joined: Mon May 12, 2008 9:14 am

Need Help cant remove certain feilds from files

Post by evin1207 »

I want to manipluate the string $xml but im having dificulty ive str_replace with no luck any i deas

Code: Select all

 
<?php
$xml = "";
$putdata = fopen( "php://input" , "rb" );
$dest_xml='/var/www/webupload/scribe'.date("H:i:s").".xml";
$file = fopen($dest_xml, "a", 0);
while(!feof( $putdata )) {
$_data = fread($putdata, 4096);
$_data = urldecode($_data);
$xml = $xml.$data;
}
$response = str_replace("response=","","$xml");
fclose($putdata);
fclose($file);
?>
 
:banghead:


this is my ouput with out the str_replace.

Code: Select all

 
response=<response><external-xml></external-xml><external-id>789456123</external-id><audio-duration>15</audio-duration><trans-xml><message><![CDATA[This is a test.  Test 1, 2.  Test 1 2 3.  1, 2, 3, 4, 5, 6, 7, 8, 9, 10.  (??) here communication.]]></message><result>transcribed</result></trans-xml><metadata/><truncated>false</truncated><error-code>0</error-code><ss-id>254126455</ss-id></
 

any help would be very appreciated.
Dutchben
Forum Newbie
Posts: 12
Joined: Wed May 14, 2008 10:19 am

Re: Need Help cant remove certain feilds from files

Post by Dutchben »

First i've noticed that in your example your not building $xml correctly
# $_data = fread($putdata, 4096);
# $_data = urldecode($_data);
# $xml = $xml.$data;
should be
# $_data = fread($putdata, 4096);
# $_data = urldecode($_data);
# $xml = $xml.$_data;
or $xml .= $_data; for schort

$response = str_replace("response=","","$xml"); is correct. How are you outputting?
Post Reply