Results 1 to 7 of 7
-
22nd Jul 2010, 01:53 PM #1OPMemberWebsite's:
maxneeds.infoCount a function true/false
PHP Code:foreach($filenames as $count){
$filedup=basename($count,'.txt');
$filedup=array($filedup);
print_r (array_count_values($filedup));
}
Code:Array ( [entry090914-020018] => 1 ) Array ( [entry091129-053238] => 1 ) Array ( [entry100716-184512] => 1 ) Array ( [entry100718-111228] => 1 )
How can i do this in one array only ?
Example:Code:Array ( [entry090914-020018] => 1 ,[entry091129-053238] => 1 ,[entry100716-184512] => 1 ,[entry100718-111228] => 1 )
Porsche_maniak Reviewed by Porsche_maniak on . Count a function true/false foreach($filenames as $count){ $filedup=basename($count,'.txt'); $filedup=array($filedup); print_r (array_count_values($filedup)); } But this gives Array ( => 1 ) Array ( => 1 ) Array ( => 1 ) Array ( => 1 ) So the array_count_values function does not work because everything is in separate array and that seems to be from foreach. Rating: 5
-
22nd Jul 2010, 03:05 PM #2MemberWebsite's:
ExpresShare.comif I did understan what you mean this code is what you want ::
PHP Code:$bla=array_unique($array);
if isset($bla)
$count=count($array)-count($bla)
else
$count=0;
-
22nd Jul 2010, 07:20 PM #3OPMemberWebsite's:
maxneeds.infoWhat i am trying to do is to count all duplicates in array and show them as number.
Eg:
array('fish','dog','pants','male','fish','fish','m ale')
I need to echo 3 fishes and 2 males
Note : I don't know the array content,neither the searching string.The function has to search for duplicates between the array values.
-
22nd Jul 2010, 07:35 PM #4MemberWebsite's:
pspmafia.com zrev.netyou can probably use in_array() and search each spot using a for loop
for($i = 0; $i < $arrayMax; $i++){
$total = 0;
if(in_array($array[$i]), $array){
$total = $total+1;
}
}
Somewhere along those lines.
EDIT: nevermind, just read your note, lol.
EDIT 2.0: was looking online, found something that may help.
Code:<?php function arrayDuplicate($array) { return array_unique(array_diff_assoc($array1,array_unique($array1))); }; ?> Example: <?php $arr1 = array('foo', 'bar', 'xyzzy', '&', 'xyzzy', 'baz', 'bat', '|', 'xyzzy', 'plugh', 'xyzzy', 'foobar', '|', 'plonk', 'xyzzy', 'apples', '&', 'xyzzy', 'oranges', 'xyzzy', 'pears','foobar'); $result=arrayDuplicate($arr1); print_r($result);exit; ?> Output: Array ( [4] => xyzzy [12] => | [16] => & [21] => foobar )
Trusted & Respected Members:
ACiD | Narutoroot | JmZ | Jackson | Phamous | litewarez
-
24th Jul 2010, 04:34 PM #5OPMemberWebsite's:
maxneeds.info*********
-
24th Jul 2010, 06:44 PM #6MemberWebsite's:
litewarez.net litewarez.com triniwarez.comPHP Code:function arrayDuplicates($array)
{
$check = array(); //Temporary
foreach($array as $item)
{
isset($check[$item]) ? ($check[$item]++) : ($check[$item] = 1);
}
return $check;
}
Join Litewarez.net today and become apart of the community.
Unique | Clean | Advanced (All with you in mind)
Downloads | Webmasters
Notifications,Forum,Chat,Community all at Litewarez Webmasters
-
25th Jul 2010, 09:08 AM #7OPMemberWebsite's:
maxneeds.infotnx litewarez but the problem is that the stupid foreach function adds each value to separate array as i wrote above.So the function is useless if it is not in one array.
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Depositfiles False Payment Info
By piratebay in forum File Host DiscussionReplies: 11Last Post: 1st Jan 2011, 06:36 PM -
True or false? [Game]
By Daniel in forum General DiscussionReplies: 48Last Post: 1st Sep 2010, 05:52 PM
themaCreator - create posts from...
Version 3.45 released. Open older version (or...