Re: Regular expressions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Gustav Wiberg wrote:
<?php
$lines = file('export/nhExportVarupiraten.txt');

// Loop through our array, show HTML source as HTML source; and line numbers too.
foreach ($lines as $line_num => $line) {

echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br />\n";

if ($line_num > 0 ) {
 $getName = explode('<>', $line);
 $pattern = "/ID=([0-9]*)\</";
 $subject = $line;
 $idNumber = preg_split($pattern, $subject);

// instead of preg_split, use preg_match

$idNumber = preg_match($pattern, $subject, $matches);

// your ID number is now in $matches[1]


 echo "NAME = " . $getName[2] . " has ID number=$idNumber[0]<br>";
}
//require("phpfunctions/opendb.php");
//$sql = "UPDATE beskrivandeVarunamn=" . safeQuote($bNamn) . " WHERER"
//mysql_close();

}

?>

--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux