eeeee Posted September 26, 2006 Share Posted September 26, 2006 Just registered here, so: "Hello to all!"I started learning PHP 3 days ago, because i need it to solve my problem. Because of my slow progres i was hoping someone here might be able to help me...My data is in a large file, here is a short example:[code]###x###x###x###x###<img [LOGO]logo.jpg[/LOGO]</a><a href="javascript:void(0);" onClick="openPop_new('index.php@dep_id=1&layout=112&picture_id=483', 'picture', 100, 100, '');"><img src="images/icon_zoom_small.gif" width="10" height="10" border="0"></a>[NAME]WTF[/NAME]<img src="images/11/icon_new_window.gif" border="0" align="absmiddle" /></a><a target="_blank" href="index.php@dep_id=1&layout=71&subject=152"><img src="images/11/icon_print_s.gif" border="0" align="absmiddle" /></a><a href="[EMAIL]info@wtf.com[/EMAIL][ADDRS]xxx 3 [/ADDRS][OB]1000[/OB]###y###y###y###y###[/code]The data for one of many clients is between ###x###x###x###x### and ###y###y###y###y###Information for one client is between tags like [NAME]bla[/NAME], [ADDRS], [OB],...Not all clients have all of these tags.I would like to my php script to output just:1;logo.jpg;WTF;info@wtf.com;xxx 3;1000(1 - number of client, which is incremented, the rest is text between tags[LOGO],[NAME],[EMAIL])If some tags do not exist between ###x###x###x###x### and ###y###y###y###y###, their value should be "0".Example: If the [LOGO][/LOGO] tag wouldnt exist, the output would be:1;0;WTF;info@wtf.com;xxx 3;1000--------My code so far ???:[code]<?php$file = file_get_contents('data.txt');preg_match("/\[NAME\](.+?)\[\/NAME\]/", $file, $nameX);$name = $nameX[1];preg_match("/\[ADDRS\](.+?)\[\/ADDRS\]/", $file, $addrsX);$addrs = $addrsX[1];echo "$name; $addrs";?>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.