vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Using preg_match_all... (https://vborg.vbsupport.ru/showthread.php?t=286763)

m002.p 08-30-2012 07:16 PM

Hi kh99,

The issue is actually this, not the preg_match_all.

Code:

$p1 = "/BOT report (.*),(.*)/siU";
                if (preg_match_all($p1, $console['chat'], $out1))
                {
                        // Define variables for actions
                        $post_data = array();
                        $post_data['id'] = $out1[1];
                        $post_data['reason'] = $out1[2];
                        // More $post_data array vars here
                    }

The $out1[] vars always print as arrays despite my [1] offset. I dont see the point of a foreach here as there is usually only one line sent into the preg_match_all so I wanted to output the content as above.

Any ideas how to get the elements of the array?

kh99 08-30-2012 08:22 PM

Yeah, check out the description for preg_match_all, the part about the flags: http://us2.php.net/manual/en/functio...-match-all.php. There's two levels of array, but you should be able to get at what you want by using something like $out1[0][0] or $out1[0][1]. Or, if you only expect one match it might be easier to use preg_match() instead.


All times are GMT. The time now is 11:16 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.00919 seconds
  • Memory Usage 1,714KB
  • 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
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete