Yngvarr

Generation

generate functionMon, 17 Apr 2023

после каждой цифры вставить случайную букву

<?php function randomChar($list){ return $list[rand(0, strlen($list) - 1)]; } function afterEachNum(string $str){ $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; $result = ''; for($i = 0; $i < strlen($str); $i++){ if(is_numeric($str[$i])){ $result .= $str[$i].randomChar($chars); } else { $result .= $str[$i]; } } return $result; } echo afterEachNum('12345');

Questions about programming?Chat with your personal AI assistant