Hi,
Ik doe het volgende nu:

if(preg_match('/alu/', $row[10])){$row[2] = $row[2].' aluminium';  }
elseif(preg_match('/red/', $row[10])){$row[2] = $row[2].' rood';  }
etc
etc

Kan veel korter alleen weet niet hoe :-(

Ik ben tot onderstaand gekomen maar nu moet ik het nog combineren, iemand een tip?
Iets met search array?
Thanks!

$a_kleuren = array(
    'alu'	=> 'aluminium',
    'red'	=> 'rood',
);


preg_match('/alu/', $row[10])
Volgens mij kan je hiervoor beter geen regexen gebruiken. Dit zijn simpele zoek opdrachten in strings, daarvoor kan je beter andere functies gebruiken.

Van de php site:

Do not use preg_match() if you only want to check if one string is contained in another string. Use strpos() or strstr() instead as they will be faster.
<?php
$colors = array(
'alu' => 'aluminium',
'red' => 'rood',
);

foreach ($colors as $short => $long) {
if (false !== strpos($short, $str) && $str .= ' $long');
}
?>

[offtopic]Waarom 'alu' gebruiken en niet de standaard Al?[/offtopic]
Dank Wouter, werkt!
We willen graag volledige beschrijving.
[php]variables[/php] [php]operators.comparsion[/php] [php]types.array[/php];

[php]foreach[/php] {
[php]if[/php] ([php]types.boolean[/php] [php]operators.comparison[/php] [php]strpos[/php] [php]operators.logical[/php] [php]variables[/php] [php]operators.assignment[/php] [php]string[/php])
}

Reageren