Jump to content

[SOLVED] strstr


glenelkins

Recommended Posts

i will post some example code. It makes no sense to why the strstr is not picking up the .co.uk from the first array element. The * is removed so the needle becomes .co.uk

 

$array = array ( '*.co.uk', '*.com' );

// THE ARRAY IS GENERATED FROM DATABASE SERIALIZED DATABASE VALUES. using unserialize() to create the array
// if i create the array manually then it works ok

$hostname = gethostbyaddr ( '111.111.111.111' ); // for example. server.domain.co.uk

foreach ( $array as $item ) {

    // remove the *
    // will leave .co.uk  on the first element
    $item = ltrim ( $item, '*' );

    if ( strstr ( $hostname, $item ) ) {

        die ( 'OK' );

    }

}

   

 

Link to comment
Share on other sites

here ill add a bit more for the example. lets build the array from an imaginery database table

 

$result = mysql_query ( "SELECT `data` FROM `test`" );
list ( $data ) = mysql_fetch_array ( $result );

$array = unserialize ( $data );

// array ( '*.co.uk' )

 

The strstr doesnt work with this however it will work if i do:

 

$array = array ( '*.co.uk' );

 

WTF WTF WTF

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.