note 33664 added to function.preg-split
| From: | howard at t dot php dot net | Date: | Thu, 03 Jul 2003 13:50:07 +0000 |
| Subject: | note 33664 added to function.preg-split | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-51444@lists.php.net to get a copy of this message | ||
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.
----
Manual Page -- http://www.php.net/manual/en/function.preg-split.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33664
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33664&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33664&report=yes