I've created a form where visitors can input more than one value. They have to use a space as a delimiter. For example: 'mozart beethoven grieg'.
And redundant spaces should be converted to one space.
The only exception is when a value is followed by a comma and a space.
Then the search string should be taken literally.
So if for example you filled in:
mozart amadeus, then this should be split into:
'mozart' and 'amadeus'.
But if you filled in 'mozart, amadeus' it should stay 'mozart, amadeus'.
These values shoud be seperated in put into an array.
So if someone filled in: mozart grieg, beethoven bach.
I would have an array with the values:
array[0] = mozart
array[1] = grieg, beethoven
array[2] = bach
Is it possible to adjust the preg_match_all( ) function so that it doensn't use (comma space) as a separator?
Thanks in advance,
Dimpie
And redundant spaces should be converted to one space.
The only exception is when a value is followed by a comma and a space.
Then the search string should be taken literally.
So if for example you filled in:
mozart amadeus, then this should be split into:
'mozart' and 'amadeus'.
But if you filled in 'mozart, amadeus' it should stay 'mozart, amadeus'.
These values shoud be seperated in put into an array.
So if someone filled in: mozart grieg, beethoven bach.
I would have an array with the values:
array[0] = mozart
array[1] = grieg, beethoven
array[2] = bach
Code:
preg_match_all('/[^\s]+/', $persoon, $m);
$array_persoon = $m[0];
Thanks in advance,
Dimpie