vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   BB Code using PHP? (https://vborg.vbsupport.ru/showthread.php?t=181055)

Jibba Jabbas 05-30-2008 10:02 PM

BB Code using PHP?
 
How do i go about using PHP when creating new BB Codes? Basically i want to create a new BB Code and i need to use the text between it in a PHP script...

So the process is like this:

[bbcode]test[bbcode]

Then a PHP script is run which has say $x = the user input.. in this case "test".

Then i after using that input to gather the relevant data i have it all in $a and want to print the contents of $a on the screen.

So it goes from [bbcode]test[/bbcode] to showing the contents of $a.

How do i go about doing this?

Thanks

Attilitus 05-30-2008 11:11 PM

It is easy if you know regular expressions. Here is the code you need: (Assuming that the code between the tags will be a string that doesn't contain whitespace.
PHP Code:

preg_match_all("#\[bbcode\](\w+)\[\/bbcode\]#i",$template,$matches);

foreach(
$matches[0] as $value){
//$value contains the each instance of entire blocks matched "[bbcode]stringWithoutWhitespace[/bbcode]"
}

foreach(
$matches[1] as $value){
//$value contains each instance of only stringWithoutWhitespace between the tags.


I hope this is helpful.

Jibba Jabbas 05-31-2008 10:38 AM

But can that be input into the HTML box when you create a new bbcode using admin cp?

Once i get the bit in the middle i need to do something with it through PHP then the output needs to go onto the page.

Thanks


All times are GMT. The time now is 06:45 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.00974 seconds
  • Memory Usage 1,715KB
  • 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_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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