[ create a new paste ] login | about

Link: http://codepad.org/rZlm7OeQ    [ raw code | output | fork ]

PHP, pasted on Sep 22:
1
2
3
4
5
6
7
8
9
10
11
12
<?php

$needle = 'p1';
$arr = array("lolly","lollyp1","top","topp1","bum","bump1","gee","geep1");

function find_needle($var) {
    global $needle;
    return strpos($var, $needle) !== false;
}
$ret = array_keys(array_filter($arr, 'find_needle')); 

print_r($ret);


Output:
1
2
3
4
5
6
7
Array
(
    [0] => 1
    [1] => 3
    [2] => 5
    [3] => 7
)


Create a new paste based on this one


Comments: