Notice: Uninitialized string offset in PHP

前端 未结 2 1628
予麋鹿
予麋鹿 2021-01-03 10:46

Hi I have this function and it returning a notice:

Notice: Uninitialized string offset

function generaterandomkey($length) {       

    $string=\'\'         


        
2条回答
  •  臣服心动
    2021-01-03 11:02

    the best way : convert your string expression to array and then convert to string like this:

    function readnumber know a number with any length:

    function readnumber($str, $i) 
    {
        $string=$str;
        $number = '';
        $s="";
        for($j=0;$jis_number($s[$i]))
            $number .= $s[$i++];        
        return $number;
    }
    

    can use it like this:

    $str="154+458-8";
    $number=readnumber($str,1);
    echo($number);
    

提交回复
热议问题