I will make this quick and simple
I have a query and I want to split it so that it returns an array with words after the : symbol. This is what I have so far and it does as expected but returns the whole string before the matched needle. I just want the array to contain words after the : symbol.
<?php $arr = preg_split('/[:]/', $query, 0);
print_r($arr);
?>
This returns
Array
(
[0] => SELECT user_name FROM test WHERE user_name =
[1] => user_name
)
using this query
“SELECT user_name FROM test WHERE user_name = :user_name”
thanks for any help
Try this:
By doing this, all your elements that are after a : will be in $matches[1] sub-array. I’m assuming you want to handle SQL statements with multiple named parameters. So for example:
Will result in $matches being: