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!
Look into the array_keys function. http://www.php.net/manual/en/function.array-keys.php This will return each key which contains a search string. You'd just need to count the keys and you're in business.