PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $txt = "You should eat fruits, vegetables, and fiber every fruits day."; $mass = ["fruits", "vegetables", "fiber"]; $mass2 = ["pizza", "beer", "ice cream"]; $color = ["red", "lime", "gold", "magenta", "blue", "green", "orange", "purple", "yellow", "coral"]; foreach ($mass2 as $key => &$word) { $word = "<span style=\"color: $color[$key];\">$word</span>"; } $rt = str_replace($mass, $mass2, $txt); echo $rt;
Show:  
Copy Clear