[snip] [/snip] Alice, The big problem here is that you are resetting the $string3 variable in the loop for ($j=0; $j<$count_chunk2; $j++) { $string3= $stringChunk2[$j]; // <<<------ resetting the value if ($j <$count_chunk_2) { $string2= " OR "; $string3=$string3.$string2; } else { //Don't do anything } echo $string3; } I am not sure of your goal since you have not stated it, but it certainly should be easier to just replace the PIPE with the OR $message = str_replace("|", " OR ", $message); -- Bastien Cat, the other other white meat