English 中文(简体)
阵列中高至低价值的生活安排[封闭]
原标题:Sorting High to Low value in the array [closed]
  • 时间:2012-01-14 13:43:08
  •  标签:
  • php
  • arrays

需要价值建议,帮助我提出以下问题。

function max_key($array) {
foreach ($array as $key => $val) {
    if ($val == max($array)) return $key;
    }
}

$SortingVote = array();

for ($i=0; $i<10; $i++) {

   $SortingVote[] = $i;
}

$array = $SortingVote;

$array_count=count($array);    
for($i=0;$i<=$array_count;$i++){
    $max_val[$i]=max_key($array);

    $voteValue_View=$array[$max_val[$i]];

    unset($array[$max_val[$i]]);


    $VoteValue_New[$i] = $voteValue_View;
    echo "Vote Value manual = $VoteValue_New[$i] <br />"; 
}

当我通过MAMP Mac版本(P &MySQL)在当地机器上运行时,它会进行细微的工作并显示出价值。 但是,当我在生产服务器上部署时,这丝毫没有显示。 它是 we的吗? 收到下列文件:

Vote Value manual = 

赞赏任何人能够指导我这样做。 卡车

最佳回答

我只是重述这一点,似乎更容易:

arsort($array);
foreach(array_slice($array,0,10,true) as $key => $value){
     echo "Vote Value manual = $value <br />"; 
}
问题回答

不要立即处理你的问题,但你显然在生产和你的发展服务器之间有错配置。 很可能见php.ini。 您能否查阅关于生产的php.ini? 如果是,检查是否:

log_errors = On

如果有的话,将出现伐木错误(尽管不是显示,因为它是一个生产服务器)。 在这种情况下,你们应当能够看一看错误的标志,看看它正在setting。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签