note 50747 deleted from function.strpos by nlopess
| From: | nlopess@php.net | Date: | Tue, 08 Mar 2005 20:08:05 +0000 |
| Subject: | note 50747 deleted from function.strpos by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-86128@lists.php.net to get a copy of this message | ||
Note Submitter: damy_belthazor86 at yahoo dot it
----
Hi folks! This is my first note ever! =)
Maybe you php genie already have this function but I want to post it in order to know if it works
properly. =) I just want to say I didn't test it many times =P
However this function returns all the values of a attribute of a tag :)
<?php
function getTagAttributeValues($HTMLCode,$daTag,$attribute) {
$tag = strtoupper($daTag); // elimino il problema del case-sensitive
$srcValues = array(); // preparo l'array da restituire
$index = 0; // indice dell'array
$tokens = explode($tag,$HTMLCode); // localizzo tutti i token delimitati dal tag
for($i=0;$i<sizeof($tokens);$i++){ // scorro i token
$tempStr = explode($attribute,$tokens[$i]); // localizzo i token delimitati dall'attributo
if ($tempStr[0] != $tokens[$i]) { // se il token e' valido
$srcValue = "";
$j=1;
while(substr($tempStr[1],$j,1) != "\""){ // scorro fino a trovare il carattere
"
$srcValue.= substr($tempStr[1],$j++,1); // concateno i caratteri
}
$srcValues[$index++] = $srcValue; // aggiungo il percorso trovato a quelli da restituire
}
}
return $srcValues;
}
?>