Announcement

Collapse
No announcement yet.

Help. I'm no good at this php thing.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help. I'm no good at this php thing.

    My php is a little rusty.
    I'm trying to change a value into a list of options.

    Here's what I have

    PHP Code:
    if ($suspenduser['usergroupid']!=or $ismod) { 
    I want to change the not equal 2 to is equal 4, 6, 8, 14, 15, 12, 7, 5, 11, 1, or 3


    Thanks.

  • #2
    Originally posted by vBR
    My php is a little rusty.
    I'm trying to change a value into a list of options.

    Here's what I have
    PHP Code:
    if ($suspenduser['usergroupid']!=or $ismod) { 
    I want to change the not equal 2 to is equal 4, 6, 8, 14, 15, 12, 7, 5, 11, 1, or 3


    Thanks.
    change it to this

    PHP Code:
    $numbers="1,3,4,5,6,7,8,11,12,14,15";
     
    if (
    strstr($numbers,$suspenduser['usergroupid']) or $ismod) { 
    The strstr(); function uses the first variable, as a needle, the second a haystack. If the needle is found it returns the needle and everything after it, otherwise it evaluates as false.

    Comment


    • #3
      Originally posted by Fallout2man
      change it to this

      PHP Code:
      $numbers="1,3,4,5,6,7,8,11,12,14,15";
       
      if (
      strstr($numbers,$suspenduser['usergroupid']) or $ismod) { 
      The strstr(); function uses the first variable, as a needle, the second a haystack. If the needle is found it returns the needle and everything after it, otherwise it evaluates as false.
      Thanks, I'll try that.

      Comment


      • #4
        Originally posted by Fallout2man
        change it to this

        PHP Code:
        $numbers="1,3,4,5,6,7,8,11,12,14,15";
         
        if (
        strstr($numbers,$suspenduser['usergroupid']) or $ismod) { 
        The strstr(); function uses the first variable, as a needle, the second a haystack. If the needle is found it returns the needle and everything after it, otherwise it evaluates as false.
        Arh. It don't work.
        Just gives no permission error even for user group 2.

        Comment


        • #5
          Originally posted by vBR
          Arh. It don't work.
          Just gives no permission error even for user group 2.
          PHP Code:
          if ($suspenduser['usergroupid'] ==or $suspenduser['usergroupid'] ==or $suspenduser['usergroupid'] ==or $suspenduser['usergroupid'] ==or $suspenduser['usergroupid'] ==or $suspenduser['usergroupid'] ==or $suspenduser['usergroupid'] ==or $suspenduser['usergroupid'] ==11 or $suspenduser['usergroupid'] ==12 or $suspenduser['usergroupid'] ==14 or $suspenduser['usergroupid'] ==15 or $ismod) { 
          ...did work though.

          Comment


          • #6
            PHP Code:
            [color=#000000]$numbers="1,3,4,5,6,7,8,11,12,14,15";[/color]

            [color=#000000]if (strstr($numbers,$suspenduser['usergroupid']) or $ismod) { [/color] 


            The above will reseult in TRUE because it's testing to see if there is a 2 in the string "1,3,4,5,6,7,8,11,12,14,15"

            Use this:
            PHP Code:
             $numbers = array (1,3,4,5,6,7,8,11,12,14,15); 
            PHP Code:
            [color=#000000]if(in_array($suspenduser['usergroupid'],$numbers) { [/color]
            [color=#000000]// Do something[/color]
            [color=#000000]} [/color] 
            Last edited by Beorn; Mon 20th Jan '03, 2:30pm.

            Comment

            Loading...
            Working...
            X