Jim Lucas wrote:
[snip]
if (!isset($pmatch) || substr($key,0,strlen($pmatch)) == $pmatch) {
print "$key = $value<br />";
}
[snip]
I would change the above the the following:
if ( empty($pmatch) || ( strpos($key, $pmatch) === 0 ) ) {
print "$key = $value<br />";
}
it would be slightly faster
love the "skin the cat" game!
What I like about this Jim is that the strpos() could be changed to
allow a "contains" argument rather than a "begins with" argument...
for example if you wanted to find all variable names containing 'foo'.
Something like:
if ( empty($pmatch) || (( strpos($tkey, $pmatch) === 0 ) || (
strpos($tkey, $pmatch) > 0 ))) {
print "$key = $value<br />";
}
t_foo
foo_t
t_foo_t
would all be found.
Thanks!
Donovan
--
D Brooke
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php