Oczywiście można to napisać inaczej (np. tak, żeby nie powtarzać 45435 <img src... />) ale to jest najprostrszy przykład.
<?php $tekst = 'Tutaj tekst, w którym chcemy zamienić tekst na emotikonki... A tu jakaś emotka:...niech będzie ta z językiem';
'' => '<img src="obrazek/smile.gif" />',
'' => '<img src="obrazek/jezyk.gif" />'
); ?>
<style type="text/css"> <!-- body { background-color: #000000; } .style2 { color: #FF0000; font-weight: bold; font-size: 18px; } #Layer1 { position:absolute; left:204px; top:69px; width:81px; height:22px; z-index:1; } #Layer2 { position:absolute; left:98px; top:54px; width:82px; height:20px; z-index:2; } .style3 { color: #FF0000; font-weight: bold; } --> </style> <form action="zapis.php" method="POST"> <table width="100%"> <tr> <td width="1%"><div align="center"></div></td> <td width="99%"> <div align="center"><span class="style2">Autor</span> <span class="style2"> <input name="autor" type="text" autocomplete="on" value="" size="38" /> </span></input> </div></td></tr> <tr> <td width="1%"><div align="center"></div></td> <td width="99%"> <div align="center"> <span class="style2"> Treść</span> <textarea name="tresc" cols="20" style="width: 252; height: 70;" autocomplete="off"></textarea> </div></td> </tr> <tr> <td > </td> <td> <div align="center"> <input type="submit" value="Dodaj" /> </div></td></tr> </table> <div align="center"><span class="style3">Komentarze sa własnoscia ich autorów. <br /> Autor strony nie ponosi odpowiedzialności za ich tresć!</span> </div> </form> <table class="all" border="0" width="100%"> <tr> <td><?php include "wiadomosc.php"; ?></td> </tr> </table> <meta http-equiv="Pragma" content="no-cache" /> <div align="center"></div>
<style type="text/css"> <!-- body { background-color: #CCCCCC; } a:link { color: #000000; text-decoration: none; } a:visited { text-decoration: none; color: #000000; } a:hover { text-decoration: none; color: #FF0000; } a:active { text-decoration: none; color: #FF0000; } .style2 {font-weight: bold; font-size: 36px; color: #000000;} --> </style> <p align="center" class="style2"> </p> <p align="center" class="style2">Właśnie dodałeś komentarz</p> <p align="center"><a href="dodawacz2.php"><strong>wróć</strong></a></p> <?php $tresc=$_POST['tresc']; $autor=$_POST['autor']; if ($tresc=='') { elseif ($autor=='') { else { ?>
<style type="text/css"> <!-- <meta http-equiv="Pragma" content="no-cache" /> body { background-color: #000000; } body,td,th { color: #FFFFFF; } --> </style><?php $linia=explode("\n",file_get_contents("dane.php")); // kolejne linie sa zapisywane jako kolejne elementy tablicy "linia" for($c=$ilosc-2;$c>=3;$c--) { $element=explode("|",$linia[$c]); // kolejne czesci linii sa rozdzielane jako elementy tablicy "element" echo '<table><tr><tr><tr><tr><tr><td><span style="color: #FF0000">'.$element[2].'</span></td></tr>'; echo '<tr><td><span style="color: #FF0000">Napisal: <b></span>' .$element[0].'</b></td></tr></table>'; } ?>
<?php $dane = "jakiś sobie tekst z :) (buźką) iw środku";
for ($i1=0; $i1<$ile; $i1++){ alt=\"$emoty[0]\" />",$dane); } ?>
<?php class funkcja{ function buzki($emotki) { '' => '<img src="obrazek/smile.gif" />',
'' => '<img src="obrazek/jezyk.gif" />'
); } } ?>
<?php require (funkcje.php); $c = new funkcja(); for ($i1=0; $i1<$ile; $i1++){ $dane=$b->buzki($dane); alt=\"$emoty[0]\" />",$dane); } ?>
<?php function insert_smiles($string) { $string = str_replace($act_smile[0],'<img src="'.$act_smile[1].'" border="0" alt="'.$act_smile[2].'">',$string); } return $string; } ?>
<?php require('insert_smiles.php'); $dane = ':) :( ;) jakiś tekst'; $dane = insert_smiles($dane); ?>
<style type="text/css"> <!-- body { background-color: #000000; } .style2 { color: #FF0000; font-weight: bold; font-size: 18px; } #Layer1 { position:absolute; left:204px; top:69px; width:81px; height:22px; z-index:1; } #Layer2 { position:absolute; left:98px; top:54px; width:82px; height:20px; z-index:2; } .style3 { color: #FF0000; font-weight: bold; } --> </style> <script type="text/javascript"> function emoticon(text) { text = ' ' + text + ' '; if (document.post.tresc.createTextRange && document.post.tresc.caretPos) { var caretPos = document.post.tresc.caretPos; caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text; document.post.tresc.focus(); } else { document.post.tresc.value += text; document.post.tresc.focus(); } } </script> <a href="javascript:emoticon('<serduszka>')"><img src="emoty/serduszka.gif" alt="Mr. Green" width="23" height="16" border="0" title="Mr. Green" /></a> <a href="javascript:emoticon('<sciana>')"><img src="emoty/sciana.gif" width="30" height="15" border="0" /></a> <a href="javascript:emoticon('<boks>')"><img src="emoty/boks.gif" width="37" height="15" border="0" /></a> <form action="zapis.php" name="post" method="POST"> <table width="100%"> <tr> <td width="1%"><div align="center"></div></td> <td width="99%"> <div align="center"><span class="style2">Autor</span> <span class="style2"> <input name="autor" type="text" autocomplete="on" value="" size="38" /> </span></input> </div></td></tr> <tr> <td width="1%"><div align="center"></div></td> <td width="99%"> <div align="center"> <span class="style2"> Treść</span> <textarea name="tresc" cols="20" style="width: 252; height: 70;" autocomplete="off"></textarea> </div></td> </tr> <tr> <td > </td> <td> <div align="center"> <input type="submit" value="Dodaj" /> </div></td></tr> </table> <div align="center"><span class="style3">Komentarze sa własnoscia ich autorów. <br /> Autor strony nie ponosi odpowiedzialności za ich tresć!</span> </div> </form> <table class="all" border="0" width="100%"> <tr> <td><?php include "wiadomosc.php"; ?></td> </tr> </table> <meta http-equiv="Pragma" content="no-cache" /> <div align="center"></div>
<style type="text/css"> <!-- <meta http-equiv="Pragma" content="no-cache" /> body { background-color: #000000; } body,td,th { color: #FFFFFF; } --> </style><?php $linia=explode("\n",file_get_contents("dane.php")); // kolejne linie sa zapisywane jako kolejne elementy tablicy "linia" for($c=$ilosc-2;$c>=3;$c--) { $element=explode("|",$linia[$c]); // kolejne czesci linii sa rozdzielane jako elementy tablicy "element" echo '<table><tr><tr><tr><tr><tr><td><span style="color: #FF0000">'.$element[2].'</span></td></tr>'; echo '<tr><td><span style="color: #FF0000">Napisal: <b></span>' .$element[0].'</b></td></tr></table>'; } ?>