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 32 33 34 35 36 37 38
| <?php
$_POST['idmed'] = [75,76]; // pour TEST
$tabdata = [ // pour TEST
0 => [
'id_med' => 75,
'nom' => 'AAAA',
'prenom' => 'tom',
'specialite' => 'menuiserie',
'email' => 'totolariflette@orange.fr',
],
1 => [
'id_med' => 76,
'nom' => 'BBB',
'prenom' => 'TAM',
'specialite' => 'patisserie',
'email' => 'gugusse@orange.fr',
],
];
$entete = '... #nom# #prenom# est spécialiste en #specialite# et son email est #email#. Par prudence .... ';
foreach($tabdata as $d)
{
// var_dump($d);
if( in_array( $d['id_med'], $_POST['idmed']) )
{
echo '<p>'.replace_value( $entete, $d ).'</p>';
}
}
function replace_value( $string, $arr=[] )
{
foreach( $arr as $idx => $val )
{
$string = str_replace('#'.$idx.'#', $val, $string);
}
return $string;
} |
Partager