[HELP] PHP Contains?

Status
Not open for further replies.

Sledmore

Chaturbate Livestreamer
Staff member
FindRetros Moderator
Jul 24, 2010
5,202
3,957
Uh hey, wasn't sure on title, but I'm doing a script that will check my users forum name with the actual forum name, I've got all that coded, everything works 100% but the problem is.. It works with the users group if it's set to 9, but if they have multiple groups that's where I'm confused on.

So basically I need to 'split' 'membergroupids' column which is split with a comma, I've done research but what function/method would I use?

- Cheers.
 

Adil

DevBest CEO
May 28, 2011
1,278
718
You've confused me.

Try this..
PHP:
<?php
 
$me= Variable;
 
echo "$me is confused."
 
?>
Wrong.
That php is script is flawed, lol

As for OP:
So you want a script that will work even with multiple group id's?
If so, you could use a 'hackish' way to get round it, by selecting their primary usergroup (e.g if someone is a moderator and subscriber, pick the one with most significance (mod))
 

Sledmore

Chaturbate Livestreamer
Staff member
FindRetros Moderator
Jul 24, 2010
5,202
3,957
Wrong.
That php is script is flawed, lol

As for OP:
So you want a script that will work even with multiple group id's?
If so, you could use a 'hackish' way to get round it, by selecting their primary usergroup (e.g if someone is a moderator and subscriber, pick the one with most significance (mod))

Uh, I read that but don't think that would work, they have their primary user group which would for VIPs be 9, so that would work, but mods/admins wouldn't as it'd have to select from 'membergroupids' which is split, i tried a method but I failed.

Method for this is; Select forum_name > go to forum database > check profile field > get user info on forum > usergroupid (this works for the primary usergroupid) > next step is the member groups. Which is where I am stuck ;p
 

Sledmore

Chaturbate Livestreamer
Staff member
FindRetros Moderator
Jul 24, 2010
5,202
3,957
can we see the script you've used for it?

I'll show a bit of it as I know what works and would like to keep that private.

(vbUser is getting the users info on the vBulletin database).

PHP:
$Membergroups = explode(',', $vbUser['membergroupids']);
 
if ($vbUser['usergroupid'] == 9)
{
//Works, this is for primary.
}
elseif ($Membergroups > 0)// Still chances \o/
{
//Need to somehow get '9' from membergroupids as you can see I attempted, but not suiure :{
}
else
{
// Nothing :{
}

Sorry for late reply had to fix up Obbo.
 

Joopie

Active Member
Sep 13, 2011
135
65
PHP:
<?php
//debug
$vbUser['membergroupids'] = '9,10,11';
 
$membergroupids = explode(',', $vbUser['membergroupids']);
if (count($membergroupids) > 0 && !empty($vbUser['membergroupids']))
{
foreach ($membergroupids as $groupid)
{
echo 'Do something with id: '.$groupid.'.<br>';
// your code
}
}
else
{
echo 'Nothing found?<br>';
// your error code
}
?>

Try this? :p
 

Sledmore

Chaturbate Livestreamer
Staff member
FindRetros Moderator
Jul 24, 2010
5,202
3,957
PHP:
<?php
//debug
$vbUser['membergroupids'] = '9,10,11';
 
$membergroupids = explode(',', $vbUser['membergroupids']);
if (count($membergroupids) > 0 && !empty($vbUser['membergroupids']))
{
foreach ($membergroupids as $groupid)
{
echo 'Do something with id: '.$groupid.'.<br>';
// your code
}
}
else
{
echo 'Nothing found?<br>';
// your error code
}
?>

Try this? :p

I love you Joops! :D!

I've put it together like this;

PHP:
while( $vbUser = mysql_fetch_assoc( $getVBUser ) )
{
$membergroupids = explode(',', $vbUser['membergroupids']);
if ($vbUser['usergroupid'] == 9)
{
echo "this works too..";
}
elseif (count($membergroupids) > 0 && !empty($vbUser['membergroupids']))
{
foreach ($membergroupids as $groupid)
{
if ($groupid == 9)
{
echo 'Do something with id: '.$groupid.'.<br>';
}
}
}
else
{
// Nothing :{
}
}

Reason being if primary is 9 no point going on, but cheers! :D!
 
Status
Not open for further replies.

Users who are viewing this thread

Top