Help: fwrite problem

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
soul_fly
Forum Newbie
Posts: 22
Joined: Mon Aug 24, 2009 2:24 pm

Help: fwrite problem

Post 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?
User avatar
SimpleManWeb
Forum Commoner
Posts: 57
Joined: Wed Dec 30, 2009 4:15 pm
Location: New Hampshire, USA

Re: Help: fwrite problem

Post 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.
soul_fly
Forum Newbie
Posts: 22
Joined: Mon Aug 24, 2009 2:24 pm

Re: Help: fwrite problem

Post by soul_fly »

Code: Select all

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