Fukzzs miniblogs

  • Fukzzs
    0

    Sveiki. Kā vienam echo var pievienot 2 funkcijas? reku funkcijas

    <?php
    function add_smile($txt) {

      //smaidinu saraksts
      $smilies = array(
         ':D' => 'smiley-grin.png',
         ':)' => 'smiley.png',
         ':(' => 'smiley-sad.png',
         ';)' => 'smiley-wink.png',
         ';(' => 'smiley-cry.png'
      );

      //aistašana teksta
      foreach ($smilies as $key => $val) {
         $txt = str_replace($key, ' <img src="//exs.lv/bildes/fugue-icons/'.$val.'" alt="'.$val.'" /> ', $txt);
      }
      return $txt;
    }


    ?>

    <?php
    function make_clickable($ret) {
       $ret = ' ' . $ret;
       // in testing, using arrays here was found to be faster
       $ret = preg_replace_callback('#([\s>])([\w]+?://[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]*)#is', '_make_url_clickable_cb', $ret);


       // this one is not in an array because we need it to run last, for cleanup of accidental links within links
       $ret = preg_replace("#(<a( [^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i", "$1$3</a>", $ret);
       $ret = trim($ret);
       return $ret;
    }
    function _make_url_clickable_cb($matches) {
       $ret = '';
       $url = $matches[2];

       if ( empty($url) )
           return $matches[0];
       // removed trailing [.,;:] from URL
       if ( in_array(substr($url, -1), array('.', ',', ';', ':')) === true ) {
           $ret = substr($url, -1);
           $url = substr($url, 0, strlen($url)-1);
       }
       return $matches[1] . "<a href=\"$url\" target='_blank' rel=\"nofollow\">$url</a>" . $ret;
    }
    ?>


    un reku mans echo kur gribu pievienot tās 2 funkcijs.


    echo make_clickable('<p>
      <b>' . $message->nick . '</b> @ ' . $message->created . ':<br />'
      . $message->message .
      '</p>');


    funkcija make_clickable strādā, bet kā pievienot vēlvienu? (add_smile)

    • mad
      0

      echo '<p>
       <b>' . $message->nick . '</b> @ ' . $message->created . ':<br />'
       . add_smile(make_clickable($message->message)) .
       '</p>';

      • Fukzzs
        0

        Paldies. wink_mini.gif

Atpakaļ Uz augšu