hi have the next code
<?php $search="ala salsa portocala nueve vacas"; $where="texto ala salsa nueve texto portocala verde nueve"; $search = explode(" ",$search); $old_kw = array($search['0'], $search['1'], $search['2'], $search['3']); $new_kw = array('<b>'.$search['0'].'</b>', '<b>'.$search['1'].'</b>', '<b>'.$search['2'].'</b>', '<b>'.$search['3'].'</b>'); $where = str_replace($old_kw, $new_kw, $where); echo $where; ?>
because i just started to learn php there are some things wich i don't understand very well.
my problem is the $search because the number of elements in array can vary.
in the case there are more than 4 elements everything but my problem came when i have 1-3 elements in array because i get a notice with "Notice: Undefined index: 2 or 3 etc... "
how could make $old_kw to be created in function of count($search)
so if the count($search) is 10...
$old_kw to be array($search etc etc $search and not defined by me manualy