a method of selecting random characters from given string

前端 未结 15 1946
小鲜肉
小鲜肉 2020-12-03 21:53

Can anyone help me with a solution that pulls the position and value of a random character from a given string using PHP. For example I have a a string variable $string = \

15条回答
  •  眼角桃花
    2020-12-03 22:13

    1. find the length of the string , ($length)
    2. use random function to generate random value within that range , ($a=Random.get($length))
    3. use substring function to get the value of the random position.($string.substring($a,1))

    sorry i dont know syntax for php (java \m/)

提交回复
热议问题