note 97240 deleted from function.array-keys by danbrown
| From: | danbrown@php.net | Date: | Fri, 09 Apr 2010 14:54:50 +0000 |
| Subject: | note 97240 deleted from function.array-keys by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-168085@lists.php.net to get a copy of this message | ||
Note Submitter: nekroshorume at gmail dot com
Reason: non-english
----
<?php
// Ãtima função para fazer Parse de CSS queries
// A very Good Function to Parse CSS queries
function parseQuery($exp,$key="name",$dic =
array("#"=>"id","."=>"class"))
{
for($i=0;$i<strlen($exp);$i++)
if(in_array($exp[$i],array_keys($dic)))
$key = $dic[$exp[$i]];
else
$array[$key].=$exp[$i];
return $array;
}
examples:
print_r(parseQuery($query)); return // Array ( [tag] => div [id] => 5 [class] => box )
print_r(parseQuery($query),name); return // Array ( [name] => div [id] => 5 [class] => box
)
?>