ARRAY and SEARCH Button

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

bluekhille
Forum Commoner
Posts: 25
Joined: Thu Jul 16, 2009 6:49 am

Re: ARRAY and SEARCH Button

Post by bluekhille »

i was able to display the records already im now working on searching and im getting hard time on it argh :banghead:
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: ARRAY and SEARCH Button

Post 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.
bluekhille
Forum Commoner
Posts: 25
Joined: Thu Jul 16, 2009 6:49 am

Re: ARRAY and SEARCH Button

Post 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 :?:
Post Reply