0
I have two div
<div id"opcao1"></div>
<div id"opcao1a"></div>
I am using this function to capture the id
function obterID($string) {
$res = preg_match('~id="([\w]+)"~i', $string, $IDs);
if ($res){
return $IDs[1];
} else {
return "";
}
}
But I only get the option div 1, the option div 1, does not return.
Someone knows how to do this
It wouldn’t be easier for you to get this ID with jQuery or JS?
– Kayo Bruno
Have two Ivs where? Where did you get this function? How are you using the function? In fact, why use a function that does almost the same thing as the
preg_match
, but returns only one item? It would be nice [Dit] the question and put more details, because the way it is, the context is very dependent on the imagination of each one. Explaining better increases the chance of getting a solution. Although I think simply eliminating the redundant function get ID already solves the problem.– Bacco