【问题标题】:Count all the ascending array of integer array计算整数数组的所有升序数组
【发布时间】:2015-08-28 05:35:32
【问题描述】:

我有一个问题:“计算所有整数数组的升序数组”。

我的代码:

<?php
$arrInt = array(1, 2, 3, 4, 5, 1, 2);

function numArrChildAscending($index, $indexcount, $array = array()){
    $numcount = 0;

    if ($index >= count($array) || $index < 1 || $index + $indexcount >= count($array)){
        return $numcount;
    }

    $flag = true;

    for ($i = $index; $i <= ($index + $indexcount - 1); $i++){
        if ($array[$i] <= $array[$i - 1]){
            $flag = false;
            break;
        }
    }

    if ($flag == true){
        $numcount++;
    }

    //echo 'count 1 :' . $numcount . '<br />';

    for ($i = $index + 1; $i < count($array); $i++){
        $numcount = $numcount + numArrChildAscending($i, $indexcount, $array);
    }

    //echo 'count 2 :' . $numcount . '<br />';

    for ($i = $indexcount; $i < count($array); $i++) { 
        $numcount = $numcount + numArrChildAscending($index, $i, $array);
    }

    //echo 'count 3 :' . $numcount . '<br />';


    return $numcount;
}

echo numArrChildAscending(1, 2, $arrInt);

这是结果:

Fatal error: Maximum function nesting level of '256' reached, aborting!
in D:\VertrigoServ\www\learningphp.vn\index.php on line 7

【问题讨论】:

    标签: php arrays int


    【解决方案1】:

    将此行放入您的 php 文件中。

    ini_set('xdebug.max_nesting_level', $limit)
    

    确保你已经安装了 xdebug

    【讨论】:

    • 我设置了ini_set('xdebug.max_nesting_level', 2000);ERR_CONNECTION_RESET
    【解决方案2】:

    编辑您的php.ini 文件:在XDebug section 中搜索xdebug.max_nesting_level。增加值。

    【讨论】:

    • 我在 php.ini 文件中找不到
    • 我下载了它,我把它移到哪里去了?
    猜你喜欢
    • 1970-01-01
    • 2020-08-25
    • 2022-01-15
    • 2021-10-12
    • 2021-03-25
    • 1970-01-01
    • 1970-01-01
    • 2013-11-24
    • 1970-01-01
    相关资源
    最近更新 更多