12-05-2007, 11:28 PM
|
#1 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
Variables in Regular Expession
I have a question of my own! I found out yesterday that you can add so-called variables in your regular expressions, although technically they're more like naming schemes for your array indexes. They can be done like so:
php Code:
$szText = 123; preg_match('/(?P<first>\d{1})(?P<second>\d{1})(?P<third>\d{1})/', $szText, $aMatches); print_r($aMatches);
Which would output:
Code:
Array
(
[0] => 123
[first] => 1
[1] => 1
[second] => 2
[2] => 2
[third] => 3
[3] => 3
)
My question is, aside from what the correct term for them are, is this: is there any way to prevent the function from also adding the numeric indexes to the array and leave you with a pure associative array?
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|