I want to replace a word with its synonyms but I don't it to replace the word with the original word. (Like a spinner)
This is the code that Zak_A from the forum helped me with:
For example if I write:
Honda is a sedan.
My replacement words for "Honda" are "Honda,Toyota,Nissan" so after the script runs, is it possible for it to select one of those words and output for example: Nissan is a seddan or Toyota is a sedan. Even though "Honda" is part of the list, it should skip that option since its that was found in the original text. Can someone please help me with this. Thank you!
This is the code that Zak_A from the forum helped me with:
PHP:
<?php
$text = 'Honda is a truck.';
$array1 = array( 'sedan', 'coupe', 'truck' );
$replace1 = "{sedan|coupe|truck}";
$array2 = array('Honda','Toyota','Nissan');
$replace2 = "{Honda|Toyota|Nissan}";
$tmp = str_replace($array1,'##1',$text);
$tmp = str_replace($array2,'##2',$tmp);
$result = str_replace('##1',$replace1,$tmp);
$result = str_replace('##2',$replace2,$result);
echo $result;
?>
For example if I write:
Honda is a sedan.
My replacement words for "Honda" are "Honda,Toyota,Nissan" so after the script runs, is it possible for it to select one of those words and output for example: Nissan is a seddan or Toyota is a sedan. Even though "Honda" is part of the list, it should skip that option since its that was found in the original text. Can someone please help me with this. Thank you!
Last edited: