mercredi 31 mai 2017

Using arrays in PHP, how to always change the key1 by key2 or change key2 by key1?

$myWords=array(
,array('funny','sad')
,array('fast','slow')
,array('beautiful','ugly')
,array('left','right')
,array('5','five')
,array('strong','weak')

,);


$myVar = 'This girl is very funny and fast and kick to left';

When the system finds the value of any key contained in the array, always switch to it for another value, I have these system ready, but it does a rand that sometimes falls on the same key found, and in 50% of cases it does not Value, I would always like to change.

I want to change to: 'This girl is very sad and slow and kick to right'

Or

if you find another key: 'This girl is very sad and slow and kick to right'

Switch to:

'This girl is very funny and fast and kick to left';

When one of the keys is found in the $myVar variable always make the exchange for the other key.

Thanks.

Aucun commentaire:

Enregistrer un commentaire