I am looking for a function or class that substitutes given string and returns array of all possible replacements. In other words I am seeking for a magic_function:
function magic_function( $str, $find, $replace )
{
$arr = array();
// some magic stuff
return $arr;
}
var_dump( magic_function( 'aaa', 'a', 'b' ) );
/*
should return:
Array(
'aab',
'aba',
'baa',
'bba',
'bab',
'abb',
'bbb'
);
*/
I am thinking of using explode and then somehow looping through that array, but maybe there is a simpler way? Maybe with regex? Any ideas? :)
Thank you in advance!