Array search string problem

Discussion in 'PHP' started by Nakayama, May 20, 2010.

  1. #1
    hi there.

    i've got a problem.

    imagine the following array containing several elements (lines) similar to this: tcp 0 0 0.0.0.0:12345 0.0.0.0:* LISTEN 78965 /sshd etc etc

    i've been using this code to search by "12345". i want to count how many times it apears in the array.


    $var = "12345";

    if(!in_array( $var, $users )) {
    echo "not found.";
    } else {
    $cont = $cont + 1;

    }

    echo $cont;


    problem: but this code searches complete lines, not strings in the lines... only findes if i put $var = "tcp 0 0 0.0.0.0:12345 0.0.0.0:* LISTEN 78965 /sshd etc etc" ...


    Thanks in advance!
     
    Nakayama, May 20, 2010 IP
  2. Fervid

    Fervid Well-Known Member

    Messages:
    161
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    120
    #2
    Fervid, May 20, 2010 IP