在laravel中可以从单词中的数字中找到一个位置并使其随机化?
实施例
Secret Word= haveaniceday
Laravel现在请求例如来自y
:
Whats the 12th digit from your word? Enter in text field
如果我输入y
并且它的真实重定向。
我已经尝试使用strpos
,但他们无法在每个会话中选择一个新的数字。
有什么想法吗?
答案 0 :(得分:0)
你可以做到
//An example of session declaration
session()->put('position', 12);
session()->put('string', "haveaniceday");
//Fetch the stored data from the session
$position = session('position');
$string = session('string');
//Get the twelfthcCharacter
$twelfthCharacter = $string[$position];