I have a simple string that should contain a name and a date of birth as below:
$searchParams = '12/12/1978 Bob Smithers';
or alternatively
$searchParams = 'Bob Smithers 12/12/1978';
What I need to do is split the date away from the name if the date exists within the string. I can obtain the date through the code below although this throws a few quirks if ordered as in the first example above.
$splitData=preg_split('/([0-9]{1,2})-([0-9]{1,2})-([0-9]{2,4})$/', $searchParams);
The second example returns an array:
<pre class='xdebug-var-dump' dir='ltr'>
<b>array</b>
<i>(size=2)</i>
0 <font color='#888a85'>=></font> <small>string</small>
<font color='#cc0000'>'bob smithers '</font>
<i>(length=13)</i>
1 <font color='#888a85'>=></font> <small>string</small>
<font color='#cc0000'>''</font>
<i>(length=0)</i>
What I require is to split the string into two pieces - one containing the date and one containing the name