vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   split help.. i think? (https://vborg.vbsupport.ru/showthread.php?t=60831)

magnus 01-27-2004 06:12 PM

split help.. i think?
 
I have a variable, $threadinfo[foousers], which containts a list of users separated by spaces. (ie. $threadinfo[foousers] = "foo1 foo2 foo3").

I'm trying to add code to newreply.php that will check the current user against that list, and if a positive match is found it will return foo();

I've tried using the illegal username code, but I just can't seem to tweak it right.

Any help would be appreciated. ;)

MindTrix 01-27-2004 10:21 PM

Wouldnt this be a job for good old Array??

NTLDR 01-27-2004 10:25 PM

You can only return something if you areb within a function and IIRC there are none in newreply.php anyway this should do what you want:

PHP Code:

if (in_array($bbuserinfo['username'], explode(' '$threadinfo['foousers']))) {
    
foo();
    exit;



MindTrix 01-27-2004 10:27 PM

Whats the Explode part about?? (Sorry just never seen that before)

NTLDR 01-27-2004 10:32 PM

Explodes all the values using ' ' (space) as the seperator into an array, for example:

PHP Code:

$test 'a b c d';
$array explode(' '$test);


$array = array('a''b''c'); 

The top, essentially gives you the bottom result :)

MindTrix 01-27-2004 10:35 PM

o k

Yeah i get it :) Cheers for explaining.

magnus 01-28-2004 12:23 AM

Woops, forgot about this.. actually, I have it all working using:

PHP Code:

    if (!empty($threadinfo['foousers']))
    {
        
$usernames preg_split('/( )+/'trim(strtolower($threadinfo['foousers'])), -1PREG_SPLIT_NO_EMPTY);
        foreach (
$usernames AS $val)
        {
            if (
strpos(strtolower($bbuserinfo['username']), strtolower($val)) !== false)
            {
                
foo();
            }
        }
    } 

This is just modified code from vB's Illegalname check. :D


All times are GMT. The time now is 08:40 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01642 seconds
  • Memory Usage 1,724KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete