SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Check array

  1. #1
    [Call me Bram] iBram007's Avatar
    Join Date
    Feb 2001
    Location
    Belgium
    Posts
    339
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Check array

    Ok, I've got a little problem, now I have this:
    PHP Code:
    <?
    $name
    ['bram'] = "blabla";
    $name['bram1'] = "blabla1";
    $name['bram2'] = "blabla2";
    ?>
    Well now, I have a variable called $cs, and I want to now if $cs equals to bram, bram1 or bram2...
    I tried lots of things, but It didn't work...

    A schema of what I want:
    PHP Code:
    <? if($cs == $name[]){
    echo
    "$cs = $name[]";
    }
    else{
    echo
    "error";
    }
    ?>

  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Something like this? It will loop through each element of the array until it finds a match.

    PHP Code:
    foreach($name as $bram) {
       if (
    $cs == $bram) {
          echo
    "$cs*$bram";
          
    $success true;
          break;
       }
    }
    if ( ! 
    $success ) {
       echo 
    "error";


  3. #3
    [Call me Bram] iBram007's Avatar
    Join Date
    Feb 2001
    Location
    Belgium
    Posts
    339
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SetCookie problem

    I have this now:
    PHP Code:
    setcookie('skin',$cs); 
    This works fine, but only in the directory where I set this cookie, so in my root directory, it doesn't work...
    I tought when you want your cookie works in you whole web, you didn't have to set any paths our urls in setcookie()...
    Can anyone help me?

  4. #4
    [Call me Bram] iBram007's Avatar
    Join Date
    Feb 2001
    Location
    Belgium
    Posts
    339
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can somebody help me?

  5. #5
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Set the path parameter to "/" http://www.php.net/setcookie


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •