preg_match(“/input name=\”(.*?)\" class=\“Enqtxtbox\” type=\“text\”/msU",$html,$n);
$u=$n[1];
echo $u;
this code shows error
Notice: Undefined offset: 1 in C:\xampp\htdocs
n.php on line 26
what is wrong with this code if html code is
<input class=“Enqtxtbox” type=“text” maxlength=“50” value=“” name=“dWuGvHeepjNBXHLzMCeZWZ”>
$n[1] is undefined because the pattern didn’t match, and the pattern isn’t matching because you’re matching the attributes in a different order.
can you plz give me right code
Hi there,
What is it you are trying to do exactly?
Would it be acceptable to test for the presence of "input class=“Enqtxtbox”, then extract the input’s proceeding name attribute?
E.g.
$subject = '<input class="Enqtxtbox" type="text" maxlength="50" value="" name="dWuGvHeepjNBXHLzMCeZWZ">';
$pattern = '/^<input class="Enqtxtbox".*name="(.*?)">$/';
preg_match($pattern, $subject, $matches);
echo($matches[1]);
Outputs: dWuGvHeepjNBXHLzMCeZWZ