Jump to content

[SOLVED] while()


ted_chou12

Recommended Posts

the purpose of this code is to help users that forgets to close text decorations to close them, since if they are not closed, the rest of the page becomes messy:

function textcodes($message,$type) {
$number1 = substr_count($message, "[$type]");
$number2 = substr_count($message, "[/$type]");
while ($number1 > $number2) {
$message = "$message"."[/$type]";
$number1 = substr_count($message, "[$type]");
$number2 = substr_count($message, "[/$type]");}}
textcodes($message, "b");
textcodes($message, "u");
textcodes($message, "i");
textcodes($message, "cod");
textcodes($message, "quo");
textcodes($message, "img");
textcodes($message, "url");

HOwever, it is not achieving its purpose... that is it doesnt close any text decoration codes at all, can anyone suggest me why?

Thanks

Ted

Link to comment
https://forums.phpfreaks.com/topic/36768-solved-while/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.