Page 1 of 1

Help: fwrite problem

Posted: Mon Jan 25, 2010 9:26 pm
by soul_fly
I'm trying a little project where I'm trying to parse data from website and then writing to a text file. I'm successful in the pregmatch part and also succeeded to write on text using var_export. But the output of text file doesn't seem good.

The code i wrote is as follows:

Code: Select all

 
$File = "MyOutput.txt";
$Handle = fopen($File, "a");
$customer = "DevNetwork";
fwrite($Handle, var_export($Data,1)) & fwrite($Handle, var_export($customer,1));
// $Data is used in Preg_match_all
 
It writes within MyOutput.txt as follows:

Code: Select all

array ( 0 => array ( 0 => '', ), 1 => array ( 0 => '43, North Tower, NY', ), )'DevNetwork'
But I want to write in more organized way. Like I want sample output in MyOutput.txt:

Code: Select all

DevNetwork 43, North Tower, NY
Is it possible?

Re: Help: fwrite problem

Posted: Mon Jan 25, 2010 10:33 pm
by SimpleManWeb
Yes, it's possible. What is $Data? Where are you getting that from? Post some more of your code and it will be easier to help you out.

Re: Help: fwrite problem

Posted: Mon Jan 25, 2010 10:50 pm
by soul_fly

Code: Select all

preg_match_all('/<address>(.*)<\/address>/', $str, $Data);
$Data contains the value of of address tag of my website.