SitePoint Sponsor

User Tag List

Results 1 to 14 of 14

Thread: smile problem

  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    canada
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question smile problem

    i need to make acode that in a forum u have smiles like this one : and if u dont want to press that smile button but to write this in the post box then it will become the smile like in here in vb u write
    Code:
     :)
    and it will become a smile auto.
    tnx

  2. #2
    Non-Member bronze trophy geniusgoalie's Avatar
    Join Date
    Sep 2004
    Location
    Buffalo, USA
    Posts
    979
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    are you building this forum from scratch?

  3. #3
    Obsessive designer Infizi's Avatar
    Join Date
    May 2004
    Location
    North Pole
    Posts
    450
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use ob_start($output)
    // make your page
    then
    $output = str_replace(": )", "image in here", $output);
    ob_flush($output);

    you should make ": )" into an array, and use erm, forgot..... its an array function, think its like array_key($array, ": )")
    New Design - PHP Slowly flowing in!

    Infizi Studio's

  4. #4
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    canada
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ye but could anybody write the full code and explanation for how to do that?
    cuase i kinda rusty!

  5. #5
    Non-Member bronze trophy geniusgoalie's Avatar
    Join Date
    Sep 2004
    Location
    Buffalo, USA
    Posts
    979
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes, unless there will be only one or two, you should use an array function. Tell me if the array doesn't work, in this case it should.

  6. #6
    Non-Member bronze trophy geniusgoalie's Avatar
    Join Date
    Sep 2004
    Location
    Buffalo, USA
    Posts
    979
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 50cent
    ye but could anybody write the full code and explanation for how to do that?
    cuase i kinda rusty!
    for $500

    actually do something like this:
    PHP Code:

    $smiley 
    = array(
                    
    '[ :) ]' => '<img src="smiley1.gif">'
                    
    '[ :( ]' => '<img src="smiley2.gif">',
                    
    'etc....'
                    
    ); 
    and call the function with this:
    PHP Code:
    $text str_replace(array_keys($smiley), array_values($smiley), $text); 

  7. #7
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    canada
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wow tnx alot!

  8. #8
    Non-Member bronze trophy geniusgoalie's Avatar
    Join Date
    Sep 2004
    Location
    Buffalo, USA
    Posts
    979
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no prob- is it working okay?

  9. #9
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    canada
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    testing it know!

  10. #10
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    canada
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oopps

    it show an error!

    here is the error!




    PHP Code:
    Warningarray_keys() [function.array-keys]: The first argument should be an array in e:\WebSites\ar.php on line 3

    Warning
    array_values() [function.array-values]: The argument should be an array in e:\WebSites\ar.php on line 3
    PHP Warning
    array_keys() [function.array-keys]: The first argument should be an array in e:\WebSites\ar.php on line 3 
    PHP Warning
    array_values() [function.array-values]: The argument should be an array in e:\WebSites\ar.php on line 3 


    ??

  11. #11
    Non-Member bronze trophy geniusgoalie's Avatar
    Join Date
    Sep 2004
    Location
    Buffalo, USA
    Posts
    979
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    could you please show the entire code so far?

  12. #12
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    canada
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i made a file named ar.php and in the files where i need this function of the smiles i wrote the requrie ar.php thing !

    <?php

    $text = str_replace(array_keys($smiley), array_values($smiley), $text);
    $smiley = array(
    '[ ]' => '<img src="smiles/EmoPackv14_001.gif">',
    '[ ): ]' => '<img src="smiles/EmoPackv14_002.gif">',

    );
    ?>

  13. #13
    Non-Member bronze trophy geniusgoalie's Avatar
    Join Date
    Sep 2004
    Location
    Buffalo, USA
    Posts
    979
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 50cent
    i made a file named ar.php and in the files where i need this function of the smiles i wrote the requrie ar.php thing !

    <?php

    $text = str_replace(array_keys($smiley), array_values($smiley), $text);
    $smiley = array(
    '[ ]' => '<img src="smiles/EmoPackv14_001.gif">',
    '[ ): ]' => '<img src="smiles/EmoPackv14_002.gif">',

    );
    ?>
    oh lol I thought that you had the code that you weregoing to implement this into, what would happen is $text would be the current text, and you could put it to a pseudo-action by doing something like this:

    PHP Code:
    <?php
    $smiley 
    = array( 
                    
    '[ (: ]' => '<img src="smiles/EmoPackv14_001.gif">'
                    
    '[ ): ]' => '<img src="smiles/EmoPackv14_002.gif">'
                    
                    ); 
    $text "This is sample text right now :)";
    $text str_replace(array_keys($smiley), array_values($smiley), $text);
    echo 
    $text;
    ?>

  14. #14
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    canada
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no u didnt understood me and some guys building asimple system!
    and in a page u have asmile column and u can press asmile picture and the code will be in the post where your writing somethig but u can also put the code of the smile and the smile picture will show up!
    thats what we trying to do!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •