www.webdeveloper.com
Results 1 to 2 of 2

Thread: Number of many occurences of strings in an array

  1. #1
    Join Date
    Mar 2008
    Posts
    49

    Number of many occurences of strings in an array

    Hi

    I have a problem, hope i will get sorted here.

    I have a long array which contains many strings and it can contain many occurences of a string. I want to know the total occurences of each string in this array .. i.e. how many times a string st1 has occured in this array .. is it possible with a simple and short method??

  2. #2
    Join Date
    Mar 2010
    Location
    Singapore
    Posts
    367
    Assume you using Perl

    Code:
    @array = ('findMe', 'E-ouch', 'Oh No');
    my $count = grep { 'findMe' } @array;
    print $count."\n";

Thread Information

Users Browsing this Thread

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles