homepage Welcome to WebmasterWorld Guest from 184.73.52.98
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Accredited PayPal World Seller

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
bbcode font-size
jman11




msg:4022893
 4:31 am on Nov 11, 2009 (gmt 0)

how you retrieve the font size from bbcode for example:


[size={number}]{text}[/size]

i want to use preg_replace to turn that into <span style="font-size: {number};">{text}</span>
this will be with a whole array, where the 'pre-replaced' tag is the key in an array, and the value i want to replace it with is the value like this:


$root = array(
"/blah/" => "cool"
);

thanks :D

 

JohnCanyon




msg:4022935
 6:22 am on Nov 11, 2009 (gmt 0)

$find = array(key($root), current($root));
$replace = array("{number}","{text}");
$content = "[size={number}]{text}[/size]";

echo str_replace($find, $replace, $content);

JohnCanyon




msg:4022936
 6:24 am on Nov 11, 2009 (gmt 0)

you could also use those values as tokens.. and learn from vincevincevince's one line template engine post.

One line template engine [webmasterworld.com]

Cheers.

jman11




msg:4023233
 4:48 pm on Nov 11, 2009 (gmt 0)

ok yeh im using that except using the grouped variable thins like "$1" and "$2", is there anyone to do math and divide one by 2? when i try like "content...".$1/2."more content" it like says unexpected number, this is in one of the arrays to do preg_replace by the way.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved