Thanks Jim. Works like a charm. Real sweet. Would you explain what this line does?
$out[$m[1]] = $m[2]; Learning is a real blast. Wish I would have jumped in a couple of years ago. Thanks again. Craig ><> [EMAIL PROTECTED] -----Original Message----- From: Jim Winstead [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 06, 2002 4:23 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] data from service into array Craig Westerman <[EMAIL PROTECTED]> wrote: > I'm just now trying to learn PHP. I don't know ANYTHING about XML. I don't > even have any XML reference books yet. I did create a PHP script that is > usable (see below), but there has to be a more efficient way to do it with > PHP. I'll hunt up your post on XML in the archives after I get a XML book. the example you provided isn't xml. (it has some resemblance, but it isn't xml.) here's a code snippet that will turn that format into an array: $fp = fopen($url,"r"); if (!$fp) die("could not open URL"); $out = array(); while (!feof($fp)) { $line = fgets($fp,512); if (preg_match('!<(\w+?)>(.*?)</\1>!', $line, $m)) { $out[$m[1]] = $m[2]; } } fclose($fp); print_r($out); jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php