[PHP] Regexpje

Pagina: 1
Acties:
  • 41 views sinds 30-01-2008

  • kaandorp
  • Registratie: November 1999
  • Laatst online: 16-08 20:11
Ik heb het volgende:
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$template="
{thumbnail}<br />
<b>{image_name}</b> {if image_is_new}<sup class=new>{lang_new}</sup>{endif image_is_new} ({user_name_link})
<br />
<a href={cat_url}>{cat_name}</a><br />
{if allow_comments}{lang_comments} {image_comments}{endif allow_comments}<br />
{lightbox_button}
";

echo $template;
echo "<hr>";

$reg = "/{if[ \t\r\n]+}(.*){endif[ \t\r\n]+}/siU";
$template = preg_replace($reg, "", $template);
echo $template;


Ik probeer met dit probeerseltje er achter te komen wat die regexp precies doet. Volgens mij doet ie niks anders als alle IF en ENDIF verwijderen. Klopt dat? :? Hij doet namelijk niks.

  • Mithrandir
  • Registratie: Januari 2001
  • Laatst online: 16-08 12:50
waar komt het ding weg?
Volgens mij zoekt 'ie naar if en endif (met brackets eromheen), en verwijderd hij dat alles.
Dus in dit geval dit hele stuk:
{if image_is_new}<sup class=new>{lang_new}</sup>{endif image_is_new}
en
{if allow_comments}{lang_comments} {image_comments}{endif allow_comments}

Maar dat kun je zelf toch wel uitzoeken?

Verbouwing


  • drm
  • Registratie: Februari 2001
  • Laatst online: 09-06-2025

drm

f0pc0dert

Hij doet namelijk niks.
Klopt.

zie de manual ;) Verder is het een kwestie van uitproberen.

Music is the pleasure the human mind experiences from counting without being aware that it is counting
~ Gottfried Leibniz


Dit topic is gesloten.