<?php
function dosomething($string, $else = '') {
if (empty($else))
$string = "<b>$string</b>";
else
$string = "<i>$string</i>";
return $string;
}
$input = "Some words.
[code]some code.[/code]
More words.
[quote]some code[/quote].
Other words.";
$codetag = array('[code]', '[quote]');
$codetag_rev = array('[/code]', '[/quote]');
for ($i = 0; $i < count($codetag); $i++)
$codetag_array[] = "/([sS]*$codetag[$i])([sS]+)($codetag_rev[$i])([sS]*)/e";
$input_new = preg_replace($codetag_array, 'dosomething("$1") . dosomething("$2","else") .dosomething("$3") . dosomething("$4")', $input);
echo "$inputn<hr>n$input_new";
// This becomes a huge mess and $2 doesn't get saved from being bold
echo "<hr><hr>";
// It does work fine if I only try it on one tag
$input_new = preg_replace($codetag_array[0], 'dosomething("$1") . dosomething("$2","else") .dosomething("$3") . dosomething("$4")', $input);
echo "$inputn<hr>n$input_new";
// $2 is indeed saved from turning bold
?>
So my only question is - how do I do this for multiple tags?
Or, if you want, you can simply ignore everything until now and just tell me how do I turn $input into:
// Output:
<b>Some words.
[code]</b><i>some code.</i>[/code]<b>
More words.
[quote]</b><i>some code</i><b>[/quote].
Other words.</b>;
Thanks
CE 7.1 and External GIS integration
Hi All,
please help me... my password gets encrypted but not able to get in database
hai guys, please help me... in the following function my password gets encrypted but not able to get in database.is any error in the query please help me...... <?php $email =
Curl timeout breaks script
So im having difficulties with skipping timeout error in curlmy script calls different functions my problem is lets say if in function2 is curl timeout error it wont continue with function3 but kills
Strange Oracle Query problem
Ok So I have this PHP class that talks to a Javascript class that basically creates a table of information from a database query and puts it in a sortable, filterable table. This all works fine and
reorder sql query
ok so i have this very simple code:Code: $query = "SELECT search_keywords, COUNT(search_keywords) AS counter FROM phpbb_popsearch GROUP BY search_keywords ORDER BY counter DESC limit 5";
Help on query replacing the date
Hi Pals,
single values into sql field
i have a form which i want the user to able to select multiple answers. But i want the answers to be stored into a single field on the mysql table in the back end. e.gthe user may select red + blue +
UL and LI Add Form
The idea I want here is when the user click on a character name from the drop down select bar at the bottom of the the form under case 1 and hits Add it is supposed to add it as a new LI in the UL
strtotime issue
Hey all,I'm playing around with some code, and basically the idea is:Person changes their profileI fetch some XML that has a unix timestamp for the time the person changed their profile, so it'll keep
Array becomes unset by itself?
Hi,I have a bit of experience with PHP but not extensive. It seems I cannot store any items to the array $details. The class:class Newsletter {public $details = array();function Newsletter($id)