Activity Stream
48,167 MEMBERS
6715 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 7 of 7
  1.     
    #1
    Member
    Website's:
    maxneeds.info

    Question Count a function true/false

    PHP Code: 
    foreach($filenames as $count){
    $filedup=basename($count,'.txt');
    $filedup=array($filedup);
    print_r (array_count_values($filedup));

    But this gives
    Code: 
    Array ( [entry090914-020018] => 1 ) Array ( [entry091129-053238] => 1 ) Array ( [entry100716-184512] => 1 ) Array ( [entry100718-111228] => 1 )
    So the array_count_values function does not work because everything is in separate array and that seems to be from foreach.
    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

  2.   Sponsored Links

  3.     
    #2
    Member
    Website's:
    ExpresShare.com
    if 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

  4.     
    #3
    Member
    Website's:
    maxneeds.info
    What 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.

  5.     
    #4
    Member
    Website's:
    pspmafia.com zrev.net
    you 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 
    )
    Using this it will tell you the location of the duplicates, using this you can count them up each time using $total or something
    Trusted & Respected Members:
    ACiD | Narutoroot | JmZ | Jackson | Phamous | litewarez





  6.     
    #5
    Member
    Website's:
    maxneeds.info
    *********

  7.     
    #6
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com
    PHP 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


  8.     
    #7
    Member
    Website's:
    maxneeds.info
    tnx 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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Depositfiles False Payment Info
    By piratebay in forum File Host Discussion
    Replies: 11
    Last Post: 1st Jan 2011, 06:36 PM
  2. True or false? [Game]
    By Daniel in forum General Discussion
    Replies: 48
    Last Post: 1st Sep 2010, 05:52 PM

Tags for this Thread

BE SOCIAL