bonjour à tous... je fais une recherche dans un tableau avec la fonction array_search()
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
$array_template = explode("\n", $tableau);
$tag_start = intval(array_search("<!-- BEGIN " . $type . " -->", $array_template)) + 1;
$tag_end = intval(array_search("<!-- END " . $type . " -->", $array_template)) - 1;
$tag_lenght = $tag_end - $tag_start + 1;
Le contenu du $array_template :
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[0] => <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
[1] => <html xmlns="http://www.w3.org/1999/xhtml">
[2] => <head>
[3] => <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
[4] => <title>Document sans nom</title>
[5] => </head>
[6] => <body>
[7] => <p>ha ha ha ça marche... enfin... on va bien voir !</p>
[8] => <p>test pour la classe template</p>
[9] => <!-- BEGIN liste -->
[10] =>   <ul>
[11] =>     <li>{nom}</li>
[12] =>     <li>{prenom}</li>
[13] =>   </ul>
[14] => <!-- END liste -->
[17] => </body>
[18] => </html>
Et bien mes variables retournent $tag_start->1 | $tag_end->-1 | $tag_lenght->-1 ce qui veut dire que la recherche ne se fait pas... je n'ai aucune erreur... si des fois vous avez une idée lumineuse, je suis preneur