Bonjour,

Je rencontre une erreur peu explicite :
Notice: Undefined offset: 1 in P:\BOULOT\WEB\****\_****_scripts\functions\htm_create.php on line 28

Les deux versions du code remanié ci-dessous ont pour objectif de ne prendre qu'une partie d'un contenu posté via un formulaire.

La 1ère méthode choppe le contenu en entier et supprime ce qu'il y a avant et après en trop, et la 2e méthode ne prend que ce qui est entre les deux.[/B]

1er ESSAI :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// On nettoie le code de turobolister
	$pattern1 = '#<TABLE CELLSPACING="28" CELLPADDING="0" WIDTH="100%"><TR><TD VALIGN="top"><DIV align=center>
<P><IMG src="http://www.****.com/img/blank1.gif"><BR><IMG src="http://www.****.com/img/logo****.gif"> </P>
<P><IMG src="http://www.****.com/img/blank2.gif"><BR></P></DIV>#';
	$pattern2 = '#<P>&nbsp;</P>
<DIV align=center>
<DIV align=center><FONT face=Georgia size=4><FONT size=4>
<DIV align=center></DIV></FONT></FONT></DIV></DIV></DIV></TD></TR></TBODY></TABLE>
<P>&nbsp;</P>
<P align=center><FONT face=Georgia>Pensez à visiter <A href="http://stores.shop.ebay.fr/****" target=_blank><B>nos autres objets en vente</B></A></FONT> <FONT face=Georgia>!</FONT><BR><BR><FONT face=Georgia>Ajoutez-nous à <A href="http://my.ebay.fr/ws/eBayISAPI.dll?AcceptSavedSeller&amp;mode=0&amp;preference=0&amp;sellerid=****&amp;ru=http%3A//cgi.ebay.fr/ws/eBayISAPI.dll?ViewItem&amp;item=110159416135&amp;ssPageName=STRK:MEFS:ADDVI" target=_blank><B>vos vendeurs favoris </B></A></FONT><FONT face=Georgia>!</FONT></P>
<P align=center><IMG src="http://www.****.com/img/blank3.gif"></P>
<P align=center><IMG src="http://www.****.com/img/powerseller-platine.jpg"></P>
</TD></TR><TR><TD VALIGN="top" ALIGN="center"></TD></TR></TABLE>#';
	$turbolister = preg_replace($pattern1, "", $turbolister);
	$turbolister = preg_replace($pattern2, "", $turbolister);

2e ESSAI :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
// On prend la partie nécessaire dans le code de turobolister
	$start = '<P><IMG src="http://www.****.com/img/blank2.gif"><BR></P></DIV>';
	$end = '<P>&nbsp;</P>
<DIV align=center>';
	$pattern = '#' . $start . '(.)' . $end . '#sU';
	preg_match_all($pattern, $turbolister, $match, PREG_SET_ORDER);
	$turbolister = $match[1];

Voilà, ces deux manières foirent.

Autant le 2e essai comporte une parenthèse capturante et j'ai donc moyen de me planter, autant le 1er essai est simple, la $pattern1 est bien supprimée, mais pas la 2e.

edit :

Solution donnée plus bas : nettoyer les $pattern avec preg_quote().