<?php
if($_POST)
{
$result_str []= "<hr><h2>Aperçu</h2>";
$result_str []= '<div id="content">';
foreach($simple_xml as $model)
{
$result_str []= '<div id="model">';
$string = $_POST['content'];
$expression = array(
'[IMG]',
'[PSEUDO]',
'[PAIEMENT]',
'[/PAIEMENT]',
'[INFOS]',
'[/INFOS]',
'[SEXE]',
'[LANGUES]',
'[STATUT]',
);
$replacement = array(
'<img src="' . urldecode($model->url_pic) . '" />',
urldecode($model->pseudo),
'<a href="' . urldecode($model->url_popup_paiement) . '" target="_blank" title="me voir">',
'</a>',
'<a href="' . urldecode($model->url_popup_info) . '" target="_blank" title="voir mon profil">',
'</a>',
urldecode($model->sex),
urldecode($model->langs),
urldecode($model->status),
'$0'
);
$replacement2 = array(
'$result_str []= \'<img src="\' . urldecode($model->url_pic) . \'" />\';' . "\n",
'$result_str []= urldecode($model->pseudo);' . "\n",
'$result_str []= \'<a href="\' . urldecode($model->url_popup_paiement) . \'" target="_blank" title="me voir">\';' . "\n",
'$result_str []= \'</a>\';' . "\n",
'$result_str []= \'<a href="\' . urldecode($model->url_popup_info) . \'" target="_blank" title="voir mon profil">\';' . "\n",
'$result_str []= \'</a>\'' . "\n",
'$result_str []= urldecode($model->sex);' . "\n",
'$result_str []= urldecode($model->langs);' . "\n",
'$result_str []= urldecode($model->status);' . "\n",
);
$count = count($expression);
$replace2 = preg_replace('#[^(\[[:upper:]\])|\n\r/]+#','$result_str []= \'' . "$0" . '\';' . "\n",$string);
for($i = 1; $i < $count; $i++)
{
$replace = str_replace($expression, $replacement, $string);
//$replace2 = preg_replace('#[^(?!A-Z)][^\n\r]+#','$result_str []= \'' . "$0" . '\';' . "\n",$string);
$replace2 = str_replace($expression, $replacement2, $replace2);
}
$result_str []= nl2br($replace);
$code_str []= '<h2>Code source</h2>';
$code_str []= '<textarea onlyread cols="150" rows="20">';
$code_str []= 'foreach($simple_xml as $model){' . "\n";
$code_str []= $replace2;
$code_str []= '}';
$code_str []= '</textarea>';
$code_str []= '</div>';
break;
}
$result_str []= '</div>';
echo implode("\n", $result_str);
echo '<hr>';
echo implode("\n", $code_str);
//echo show_source("index.php");
}
?>