note 47278 added to function.array-count-values

From: Date: Wed, 10 Nov 2004 00:00:42 +0000
Subject: note 47278 added to function.array-count-values
Groups: php.notes 
Request: Send a blank email to php-notes+get-80324@lists.php.net to get a copy of this message
I've got a problem with array_count_values. I first got this array: Array ( [0] => [1] => 10 [2] => 10 [3] => 10 [4] => 9 [5] => 10 [6] => 10 [7] => 1 ) Then use array_count_values to make this: Array ( [] => 1 [10] => 5 [9] => 1 [1] => 1 ) So far so good, but when I try to output nothing happends. I write like this: echo $array[10]; I've tried array_values but then my reference of which value is counted is lost. An output after array_values looks like this: Array ( [0] => 1 [1] => 5 [2] => 1 [3] => 1 ) When using array_valus the output works fine but I need to know which value that got for example 5 entries? If run true var_dump the original array_count_values array looks like this: array(4) { [""]=> int(1) ["10"]=> int(5) ["9"]=> int(1) ["1"]=> int(1) } compared to the array runned through array_values aswell: array(4) { [0]=> int(1) [1]=> int(5) [2]=> int(1) [3]=> int(1) } Not a huge difference but in the first there is " " around the keys. Don't know if it makes any difference? ---- Manual Page -- http://www.php.net/manual/en/function.array-count-values.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+47278 Delete -- http://master.php.net/manage/user-notes.php?action=delete+47278&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47278&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47278&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47278&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47278&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47278&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+47278&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#80324) next »