Search code examples
phppreg-matchpreg-match-all

Retrieve ID PHP preg_match_all


I want to retrieve "376901" from the following table:

<td class="evn_tdata_l">Reconciliation-Manager_RECON-MGMT_SFTP_T</td>
<td class="evn_tdata_l">376901</td>

Right now what I've tried is the following code:

    if (preg_match_all("/<td[^>]+?>Reconciliation-Manager_RECON-MGMT_SFTP_T<\/td><td[^>]+?>(.*)<\/td>/s", $html, $matches)) {
    print_r($matches);
} else {
    echo "No se encontró ninguna coincidencia.";

I dont see what seems to be wrong, could you please advise? Thank you.


Solution

  • add \s* between <td>

    /<td[^>]+?>Reconciliation-Manager_RECON-MGMT_SFTP_T<\/td>\s*<td[^>]+?>(.*)<\/td>/sU