PDA

View Full Version : [SOLVED] standard_error on foreach loop


omardealo
11-11-2014, 02:13 PM
Hello ,

i make a plugin [stop new thread if That it contains Banned words]
every thing is okay , but when i try print all Banned words Written by User , but Do not print all the words, only the last word .
i Used the code in a php file with ECHO to print and working good , but in plugin i have problem with standard_error Do not print, but only the last value . so Where the problem ?


$bwords = explode("|", $vbulletin->options['banwords_wordslist']);
$string = $vbulletin->GPC['message'];
$matches = array();
$matchFound = preg_match_all(
"/\b(" . implode($bwords,"|") . ")\b/i",
$string,
$matches
);
if ($matchFound)
{
$words = array_unique($matches[0]);
foreach($words as $word)
{
eval (standard_error( "Banned Words : <li>" . $word . "</li>"));
}
}

Dave
11-11-2014, 02:17 PM
Because the standard_error stops anything else once it's called, it will only loop once through the foreach loop.
Try something like this instead:

$bwords = explode("|", $vbulletin->options['banwords_wordslist']);
$string = $vbulletin->GPC['message'];
$matches = array();
$matchFound = preg_match_all(
"/\b(" . implode($bwords,"|") . ")\b/i",
$string,
$matches
);
if ($matchFound)
{
$words = array_unique($matches[0]);
eval (standard_error( "Banned Words : <li>" . implode(", ", $words) . "</li>"));
}

omardealo
11-11-2014, 04:04 PM
Because the standard_error stops anything else once it's called, it will only loop once through the foreach loop.
Try something like this instead:

$bwords = explode("|", $vbulletin->options['banwords_wordslist']);
$string = $vbulletin->GPC['message'];
$matches = array();
$matchFound = preg_match_all(
"/\b(" . implode($bwords,"|") . ")\b/i",
$string,
$matches
);
if ($matchFound)
{
$words = array_unique($matches[0]);
eval (standard_error( "Banned Words : <li>" . implode(", ", $words) . "</li>"));
}


Well, I understand
Now The result is shown like that :

Banned Words :

first word, Second word



i want every word shown in <li>

Banned Words :

first word
Second word



thanks brother Dave

Dave
11-11-2014, 04:16 PM
Then change
eval (standard_error( "Banned Words : <li>" . implode(", ", $words) . "</li>"));

to

eval (standard_error( "Banned Words : <li>" . implode('</li><li>', $words) . "</li>"));

That should do the trick.

omardealo
11-11-2014, 05:01 PM
Then change
eval (standard_error( "Banned Words : <li>" . implode(", ", $words) . "</li>"));

to

eval (standard_error( "Banned Words : <li>" . implode('</li><li>', $words) . "</li>"));

That should do the trick.

Yes I've been absent from my mind :D
thanxs brother :up: