Thanks for the attention.
For example, arrays are['aaa','bbb','ccc']
The string is " abadf@@@kjasf@@@jlasfkj@@@akfsdj@@@adskjdfda@@@sjdfas
"
Replace the " @@@
" with a random item in the array, such as
ABADFAAAkjasfCCCjlasfkjAAAakfsdjBBBadskjdfdaAAASjdfas
Or
ABADFCCCkjasfAAAjlasfkjAAAAKFSDJCCCADSKJDFDABBBSjdfas
Reply content:
Thanks for the attention.
For example, arrays are['aaa','bbb','ccc']
The string is " abadf@@@kjasf@@@jlasfkj@@@akfsdj@@@adskjdfda@@@sjdfas
"
Replace the " @@@
" with a random item in the array, such as
ABADFAAAkjasfCCCjlasfkjAAAakfsdjBBBadskjdfdaAAASjdfas
Or
ABADFCCCkjasfAAAjlasfkjAAAAKFSDJCCCADSKJDFDABBBSjdfas
You try this method, the writing is not tested, you try to trial no
function getStringReplace($array, $string){ $result = ''; $stringArray = explode("@@@", $string); foreach($stringArray as $value){ $val = array_rand($array, 1); $result .= $value.$val; } echo $result;}
array_rand
a function is used to randomly remove a cell from an array and then replace it with a preg_replace
function (note that the limit parameter =1).