Page 2 of 2

Re: ARRAY and SEARCH Button

Posted: Thu Aug 06, 2009 9:39 am
by bluekhille
i was able to display the records already im now working on searching and im getting hard time on it argh :banghead:

Re: ARRAY and SEARCH Button

Posted: Thu Aug 06, 2009 9:45 am
by jackpf
I gave you the code!!! How can you "get a hard time"!?!??! :dubious:

Look:

Code: Select all

<?php
    $array = array(
    'this is about football',
    'this is about basketball',
    'this is about....something else',
    'blah',
    'foo'
    );
    
    $search = 'basketball';
    
    foreach($array as $key => $value)
        if(!stristr($value, $search))
            unset($array[$key]);
    
    print_r($array);
That is the exact code - I've handed it to you on a plate.

Re: ARRAY and SEARCH Button

Posted: Thu Aug 06, 2009 9:49 am
by bluekhille
jackpf wrote:I gave you the code!!! How can you "get a hard time"!?!??! :dubious:

Look:

Code: Select all

<?php
    $array = array(
    'this is about football',
    'this is about basketball',
    'this is about....something else',
    'blah',
    'foo'
    );
    
    $search = 'basketball';
    
    foreach($array as $key => $value)
        if(!stristr($value, $search))
            unset($array[$key]);
    
    print_r($array);
That is the exact code - I've handed it to you on a plate.

quite confuse coz im using multidimensional arrays. i tried what you gave me but im getting errors so imtrying to fix it thanks for the code i'll just try to modify it to solve it :?: