cyan studios Posted May 21, 2008 Share Posted May 21, 2008 Hello all, I have a question that is complicated in explanation, but I think the solution is going to be like.. one word simple. I'm guessing. Here's my situation. I have a pdf form developed in Adobe LiveCycle Designer, so it outputs XML values. You can set up a button to fire these values off to a PHP file so that the XML values can be processed. I have both the form and the PHP file set up, but now I'm trying to write to a .txt file using a retrieved XML field "final1" and to turn the value of that into the contents of the .txt file. Let's look at some stuff. The form http://www.cyan-studios.net/posttest/outputtest2.pdf The .txt file http://www.cyan-studios.net/posttest/smdownload.txt The PHP code <HTML> <HEAD> <TITLE>HTTP Request Dump</TITLE> </HEAD> <BODY> <h1>HTTP Request Dump</h1> This page sends back to you what your browser or other user-agent submitted to this page. <h2>HTTP Headers</h2> <pre> <?PHP DumpArray("HEADERS", emu_getallheaders()); ?> </pre> <h2>Submitted Variables (as parsed by PHP)</h2> <pre> <?PHP echo $content_type; DumpArray("REQUEST",$_REQUEST); ?> </pre> <h2>Raw POST Body</h2> <pre> <?PHP $body = file_get_contents("php://input"); echo strlen($body); echo " bytes: <br>"; ?> <span style="background-color: #e0e0f0"> <?PHP while (strlen($body)>60) { echo substr($body, 0, 60); echo "\n"; $body = substr($body, 60); } echo $body; ?> </span> </pre> </BODY> </HTML> <?PHP # Function DumpArray ########################################################## function DumpArray($ArrayName,&$Array) { foreach ($Array as $Key=>$Value){ echo "$Key:\n$Value\n"; } # End of foreach ($GLOBALS as $Key=>$Value) } # End of function DumpArray ################################################# function emu_getallheaders() { foreach($_SERVER as $h=>$v) if(ereg('HTTP_(.+)',$h,$hp)) $headers[$hp[1]]=$v; $headers["CONTENT_TYPE"]=$_SERVER["CONTENT_TYPE"]; return $headers; } $myFile = "smdownload.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = [color=blue]"Jallopy"[/color]; fwrite($fh, $stringData); fclose($fh); ?> You get something like this on the dump: As you can see from my oh-so artistically fashioned diagram, I just want the value of key "final1", and I want to turn that into a variable. Then, I want to toss that variable in place of the word "Jallopy" in the above code (see the blue text). Any help's appreciated and shall be rewarded with cake. Link to comment https://forums.phpfreaks.com/topic/106623-stick-an-xml-value-into-a-variable-for-file-writing/ Share on other sites More sharing options...
CodeJunkie88 Posted June 15, 2008 Share Posted June 15, 2008 Hi! First of all I have to tell you I've only been using PHP for 4 months or so I'm not completely sure the solution I'm about to describe is the best way to do this. That said, I would generate temporary php script where the value of final1 is now used as a variable. Your main script would write a few lines of php code into a .php file and then call the generated .php file. Does that make sense to you? Link to comment https://forums.phpfreaks.com/topic/106623-stick-an-xml-value-into-a-variable-for-file-writing/#findComment-565920 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.