vendredi 16 août 2019

Simplify How to Call the Function PHP

I have code to replace a word if that word contained in the array. The code its work but there is problem first it's too long and I can't repeat the code(call the result two or more time in page). I want to simplify how to call the function and can repeat to call the result. Here is my code :

$str = 'APPLE';
$fruits = array('APPLE', 'BANANA', 'AVOCADO');
$string = $str;
foreach ($fruits as $url) {if (strpos($string, $url) !== FALSE) { echo "FRUIT"; return true; }}echo $string;return false;

For that code, I want to call the result just using $group. Thank all...

Aucun commentaire:

Enregistrer un commentaire