i try to search and replace array element inside string but don't know how to do this ! my code ex :
function check_strings($string_text){
$string_text = 'some random text with random lenght '; //random text with randon lenght
$array_of_3000 = ['some','text','hello','no','why','oh','random']; // array with lenght of 3000
$text_tokens = explode($string_text,' ');
foreach($text_tokens as$token_index =>$token ){
if (in_array($token, $array_of_3000)){
// replce $token with new_token => <a href='site_url('/$token')'> $token </a> on $string_text
//update $string_text
}
}
return $string_text;
}
how can i do it ? thanks for your helps :)
Aucun commentaire:
Enregistrer un commentaire