Thursday 30 August 2018

How to combine these two tables and echo them in PHP?

How can I combine the following arrays? For example the first $match with the first $register and after that, to echo the array

$matches = array();
$registration = array();

preg_match_all('#(69\d{8}|21\d{8}|22\d{8}|23\d{8})#', $str2, $matches);
preg_match_all('!<td class="registration">(.*?)</td>!is', $str2, $registration);

foreach ($matches[1] as $match) {
    echo $match.'<br>';
}
foreach ($registration[1] as $register) {
    echo $register.'<br>';
}


Try with this example :
foreach (array_combine($matches[1], $registrations[1]) as $matche => $registration) {
        echo $matche." - ".$registration;
    }

and an other post like as your : Two arrays in foreach loop

0 comments:

Post a Comment