1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| <?php
$codes = array(234543, 245984, 343298);
$reps = array(
array(
'reduit' => 'DC',
'libellé' => 'Ceci est un commentaire libre qui contient toujours un code 245984',
'fax' => '0345678909',
'telephone' => '0345678909'
),
array(
'reduit' => 'GF',
'libellé' => 'Ceci est un commentaire libre qui contient toujours un code 343298',
'fax' => '0312345678',
'telephone' => '0398765432'
)
);
// extraction des libellés : array(numero => libellé)
$libelles = array();
foreach($reps as $data) {
$match = preg_match('/(\d)+/i', $data['libellé'], $nums);
if ($match) {
$libelles[$nums[0]] = $data['libellé'];
}
}
$keyCodes = array_flip($codes);
$crossData = array_intersect_key($libelles, $keyCodes);
?> |
Partager