PDA

View Full Version : Using | as a separator


TheInsaneManiac
08-24-2008, 03:44 AM
I seem to have run into a snag with my product. Everything had been going smoothly using the current "|" script I have, but for some reason I can't figure out how to make allowedids be able to separate with the "|"

$valid_ids = $vbulletin->options['allowedids'];
if ($vbulletin->userinfo['userid'] != $valid_ids)

I also tried someone elses way:

$valid_ids = explode("|", $vbulletin->options['allowedids']);
if ($vbulletin->userinfo['userid'] != $valid_ids)

No success yet. Suggestions?

Digital Jedi
08-24-2008, 03:54 AM
Will using the ASCII code for the pipe work? & # 1 2 4 ;

RLShare
08-24-2008, 04:59 AM
explode returns an array of the elements that were seperated by the '|' therefore you should use the in_array function to check and see if the ID is in the array.

$valid_ids = explode("|", $vbulletin->options['allowedids']);
if (!in_array($vbulletin->userinfo['userid'], $valid_ids))
{
//userid not in the option
}

TheInsaneManiac
08-24-2008, 02:44 PM
explode returns an array of the elements that were seperated by the '|' therefore you should use the in_array function to check and see if the ID is in the array.

$valid_ids = explode("|", $vbulletin->options['allowedids']);
if (!in_array($vbulletin->userinfo['userid'], $valid_ids))
{
//userid not in the option
}
Thanks man. It worked. I remember trying an array to do it, but still couldn't get it to work. Maybe I missed something, I don't know. Anyway thanks a lot!