Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    convertire tutti i caratteri in codice html

    Salve a tutti,
    io avrei la necessità di trovare una funzione che mi converta tutti i caratteri di una frase in codice html, dagli spazi ai caratteri speciali tutto completamente...
    esempio

    27/06/2006
    dovrebbe diventare
    27%2F06%2F2006


    nessuno può aiutarmi?

  2. #2
    mi pare di capire che debba convertire la stringa nel formato usato per gli URL. giusto?
    http://it.php.net/manual/it/function.urlencode.php

  3. #3
    Esattamente!
    grazie mille!

  4. #4
    eccoti qua la funzione, baby

    codice:
       1.  <?php
       2. define("NL", "\r\n");
       3. define("TAB", "\t");
       4. $output = array();
       5. if ($_POST) {
       6. echo '<h3>The Result</h3>'.NL;
       7. $html_by_line = split("\n", $_POST["html"]);
       8. if (!isset($_POST["make_list"])) {
       9. $start = "";
      10. $output[] = '
    1. '; 11. foreach ($html_by_line as $key => $line) { 12. $class = ($key % 2) ? ' odd' : ''; 13. if (trim($line) == "") { 14. $output[] = TAB.'<li class="'.$class.'">&#160;'; 15. } 16. else if (preg_match("/^(\s)+/", $line, $regs)) { 17. $output[] = TAB.'<li class="tab'.strlen($regs[0]).$class.'">'.highlight_string(trim($line), true).''; 18. } 19. else { 20. $output[] = TAB.'<li class="'.trim($class).'">'.highlight_string(trim($line), true).'</code>'; 21. } 22. } 23. $output[] = '
    '.NL; 24. $echo = join(NL, $output); 25. 26. echo stripslashes($echo); 27. echo '<pre>'.stripslashes(htmlentities($echo)).'</pre>'; 28. } 29. else { 30. foreach ($html_by_line as $line) { 31. if (preg_match("/^(\s)+/", $line, $regs)) 32. $start = str_pad($start, strlen($regs[0]), ''); 33. if (trim($line) == "") 34. $output[] = NL; 35. else 36. $output[] = $start . htmlentities(trim($line)).NL; 37. } 38. $echo = join(NL, $output); 39. echo '<pre><code>'.$echo.'</code></pre>'.NL; 40. } 41. } 42. else if ($_GET) {echo "you need to post the code";} 43. ?>

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.