[php] ubb [list=?]

Pagina: 1
Acties:

  • Vulpecula
  • Registratie: April 2001
  • Laatst online: 17-09 23:05
Ik heb het volgende gemaakt.
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?
$a1 = explode("[list=1]", $artikel);
   for ($i1=0; $i1<count($a1); $i1++) {
     $b1 = strpos($a1[$i1], "[/list]");
     if ($b1)
        $a1[$i1] = "<OL>".str_replace("[*]", "<LI>", substr($a1[$i1], 0, $b1))."</OL>".substr($a1[$i1], $b1 + 7);
     }
 $a2 = explode("[list=a]", $artikel);
   for ($i2=0; $i2<count($a2); $i2++) {
     $b2 = strpos($a2[$i2], "[/list]");
     if ($b2)
        $a2[$i2] = "<OL type=A>".str_replace("[*]", "<LI>", substr($a2[$i2], 0, $b2))."</OL>".substr($a2[$i2], $b2 + 7);
     }
$artikel = implode("", $a1);
$artikel = implode("", $a2);
?>

Maar als ik nu [list=1]
intyp wordt er telkens <ol type=a> neergezet terwijl dit eigenlijk <OL> had moeten zijn. Weet iemand hoe dit komt?

  • Vulpecula
  • Registratie: April 2001
  • Laatst online: 17-09 23:05
Ik heb deze hier gevonden, alleen wat moet ik achter die [list= zetten?
PHP:
1
2
3
4
5
6
7
8
9
10
11
<?
function process_list($items,$type="disc") {
  # verander $type in disc al een ongeldige waarde is opgegeven
  if ( ($type != "disc") AND ($type != "square") AND ($type != "circle") ) $type = "disc";
  $return = "<ul type=\"" . $type . "\">";
  $return .= preg_replace("/\*(.+?)/s","<li>\\1</li>",$items);
  $return .= "</ul>";
  return $return;
 }
 $artikel = preg_replace("/\\[list( type=(.*?)){0,1}\]((\*(.+?))*?)\\[\/list\]/es","process_list('\\3','\\2')",$artikel);
?>