As an example, my string might look like this:
first_name:Tom last_name:Jones email:tom@somedomain.com
I would want my array to look like the following:
Array (
['first_name'] => 'Tom',
['last_name'] => 'Jones',
['email'] => 'tom@somedomain.com'
)
This will then be used to search the database based on the column and value. So I will first need to retrieve the key (such as first_name) and the value (like Tom) for searching.
I have the following regex:
((?:[a-z][a-z0-9_]*))
This works. It finds all strings before :
and after :
, but I cannot figure out how to parse this to put it in an array of the format I need.