note 33664 deleted from function.preg-split by sniper
| From: | sniper@php.net | Date: | Tue, 30 Sep 2003 12:36:02 +0000 |
| Subject: | note 33664 deleted from function.preg-split by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-57495@lists.php.net to get a copy of this message | ||
Note Submitter: howard @t freetimers dot commodore64
----
regarding START END delimiters, esp. re: PHP error "No ending delimiter '^'
found"
if I want to split a string into an array, based on a line starting with "Date:"
<?
$allOrders = "Date: 26/04/2003
product: some stuff
comments: blah blah
Date: 28/04/2003
product: some other stuff
comments: blah blah blah
Date: 13/04/2003
product: a lot of stuff
comments: purchase Date: 24/03/2003";
$orders = preg_split('^(Date:)',$allOrders);
//won't work, but
$orders = preg_split('^(Date:)^',$allOrders);
//will work.
?>
as you can see by the string, I can't just split it on lines containing "Date:"
hope that helps! please reply by email if this is hopelessly wrong; it works for me.