> try this:
>
> $string = "3/01/2005 29/12/2005 2/01/2006 20/02/2006 28/12/2006 1/01/2007
> 15/02/2007";
> $array = explode(' ', $string);
> foreach ($array as $value) echo "Date: $value<br />";
If the user separates the dates by an enter in the textarea, you need to
explode on "\r\n". To be able to handle both, you need to use split() or
preg_split().
When I use
$datelist=$_POST[datelist];
$string=explode('\r\n',$datelist);
echo $string;
foreach ($string as $value) {
echo "Date: $value<br>\n";
this is what I get:
ArrayDate: 24/12/2018 26/12/2018 31/12/2018 14/02/2019 14/03/2019 20/06/2019
24/06/2019 26/06/2019 27/06/2019 27/06/2019
This solved the issue, although I find it rather bizar:
$datelist=$_POST[datelist];
$string=preg_split('/\r\n/', $datelist, -1, PREG_SPLIT_OFFSET_CAPTURE);
echo $string;
foreach ($string as $value) {
echo "Date: $value<br>\n";
}
Btw the input is a copy/paste from within a program
Thx all
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php