View Single Post
  #5  
Old 11-26-2004, 02:50 AM
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Location: Knoxville TN
Posts: 774
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm almost there, but I have one remaining problem. Here's my code

PHP Code:
//################ Do Mana Cost tag ######################

// Valid Characters to search for
$mana_find = array( "W""U""B""R""G""T""X""Y""Z""1""2""3""4""5""6""7""8""9""0");

// Replacement Strings to insert
$mana_replace = array(
    
'<img src="http://www.wizards.com/images/symbols/Symbol_W_mana.gif">',
    
'<img src="http://www.wizards.com/images/symbols/Symbol_U_mana.gif">',
    
'<img src="http://www.wizards.com/images/symbols/Symbol_B_mana.gif">',
    
'<img src="http://www.wizards.com/images/symbols/Symbol_R_mana.gif">',
    
'<img src="http://www.wizards.com/images/symbols/Symbol_G_mana.gif">',
    
'<img src="http://www.wizards.com/images/symbols/Symbol_T_mana.gif">',
    
'<img src="http://www.wizards.com/images/symbols/Symbol_X_mana.gif">',
    
'<img src="http://www.wizards.com/images/symbols/Symbol_Y_mana.gif">',
    
'<img src="http://www.wizards.com/images/symbols/Symbol_Z_mana.gif">',
    
'<img src="http://www.wizards.com/images/symbols/Symbol_1_mana.gif">',
    
'<img src="http://www.wizards.com/images/symbols/Symbol_2_mana.gif">',
    
'<img src="http://www.wizards.com/images/symbols/Symbol_3_mana.gif">',
    
'<img src="http://www.wizards.com/images/symbols/Symbol_4_mana.gif">',
    
'<img src="http://www.wizards.com/images/symbols/Symbol_5_mana.gif">',
    
'<img src="http://www.wizards.com/images/symbols/Symbol_6_mana.gif">',
    
'<img src="http://www.wizards.com/images/symbols/Symbol_7_mana.gif">',
    
'<img src="http://www.wizards.com/images/symbols/Symbol_8_mana.gif">',
    
'<img src="http://www.wizards.com/images/symbols/Symbol_9_mana.gif">',
    
'<img src="http://www.wizards.com/images/symbols/Symbol_0_mana.gif">'
    
);
    
// Now for the fun part - first we define our tag.
$manastring_find "#\[mctwo\](.*)\[/mctwo\]#esiU";

// Cross our fingers.
$output preg_replace($manastring_find'str_replace($mana_find, $mana_replace, $1)'$output); 
My problem is that the prereq is now searching the string twice. I'd like to be able to have border="0" alt="X" in the img name, and be able to include lower case w, u, b, r, g, x, y, z, and t; but when I do the thing screws up royally because it tries to replace those characters whereever they occur within the img tag. This sets up an infinite loop.

How do I stop it from searching through the string twice?
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01812 seconds
  • Memory Usage 1,782KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete