OK, I have this file:
<web stuff>
<?php
$CID_FILE= 'vonage.callers';
$lines=file($CID_FILE);
foreach ($lines as $line) {
$cid=preg_split('^([^,]+),\s?(.*)', $line, -1,
PREG_SPLIT_DELIM_CAPTURE);
}
?>
<web stuff>
the trouble is, $cid is empty. The actual file has lots of print
lines, so I know that $lines is an array with each line for $CID_FILE
as one element of the array and that $line gets the data from a
single array element correctly.
What I want is for each line to be an array, split at the first
comma. The regex works in BBEdit, where I can search for
^([^,]+),\s?(.*)
and replace with
\2 \1
and it does the right thing, over and over, so the regex is not the
issue. It's something that I am not doing right/understanding in
preg_split. I've also tried:
$cid=preg_split('^([^,]+),', $line);
$cid=preg_split('^([^,]+),\s?(.*)', $line, PREG_SPLIT_DELIM_CAPTURE);
$cid=preg_split('^[^,]+,', $line, -1);
$cid=preg_split('^[^,]+,', $line);
The actual code with the extra printing is here:
<http://akane.covisp.net/~kreme/vonage.phps>
<http://akane.covisp.net/~kreme/vonage.php>
and the sample data is
<http://akane.covisp.net/~kreme/vonage.callers>
--
No one ever thinks of themselves as one of Them. We're always one of
Us. It's Them that do the bad things.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php