folgendes Problem: Das "li" -Tag von der oberen "Liste" ist nicht richtig eingestellt und dann ist es. Ich habe versucht, Ausdrücke zu ändern, aber ich habe noch keine Lösung gefunden.Parse BBCode mit Arrays
Dies ist mein (shortended) Code (und alle anderen "bb" s nach dem gleichen Schema)
function bb($content) {
$search = array (
'#\[list\](.+)\[\/list\]#iUs',
'#\[list=1\](.+)\[\/list\]#iUs',
'#\[\*\](.*)\[/\*\]#iUs',
'#\[IMG\](.+)\[\/IMG\]#iUs'
);
$replace = array (
'<ul>$1</ul>',
'<ol>$1</ol>',
'<li>$1</li>',
'<img src="$1"/>'
);
$newtext = preg_replace($search, $replace, $content);
$newtext = nl2br($newtext);
$newtext = preg_replace('#<br />(\s*<br />)+#', '<br />', $newtext);
return $newtext;
}
print autolink(bb($NewsItemContent)); // http/s autolinking (later I'll add link preview)
Inhalt wird wie folgt aussehen:
[h1]MAIN FEATURES[/h1] [list] [*]Doubles https://steamcommunity.com/games/227300/announcements/detail/1294067099912833659 [*]Background screen options [*]Changed light flares on the player and AI vehicles https://steamcommunity.com/games/227300/announcements/detail/1335730452506903011 [/list] [h1]MINOR CHANGES[/h1] [list][*]Auxiliary brakes system support (engine brake and retarder in one control element)[/*][*]Fixed licence plate change in states/countries where no city formats exist[/*][*]Fixed brake vs parking brake behavior[/*][*]Fixed tire noise of silent tires[/*][*]Retarder improvement (better cruise control behavior, no braking with throttle, icon when moving only)[/*][*]Steam Inventory support to allow for distributing rewards from upcoming World of Trucks events[/*][/list] If you wish to participate in the open beta, you can find this version in the public_beta branch on Steam. The way to access it is as follows: Steam client → LIBRARY → right click on Euro Truck Simulator 2 → Properties → Betas tab → public_beta → 1.28 public beta. No password required. During open betas, there is a dedicated beta site for World of Trucks, which is used to safely test all new features.
I hoffe jemand kann mir helfen, Prost
Könnten Sie bitte zeigen, was * Inhalt * Sie 'bb' sind zu senden? –
Entschuldigung dafür, ich werde es jetzt aktualisieren. // Es wurde aktualisiert – Kaan2106
Kein Problem gelöst, aber dieses '' # \ [\ * \\] (. *) \ [\/\ * \\] # iUs'' passt nur zu diesem '[* \] asdf [/ * \] '.. und es sollte das sein' '# \ [\ * \] (. *) \ [/ \ * \] # iUs'' Auch mit '. *' wird am Ende der Zeile übereinstimmen, sogar andere Tags. – sln