Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 28

Thread: FUNCTION

  1. #11
    Join Date
    May 2007
    Location
    Nebo, NC, USA
    Posts
    2,517
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Sangreal View Post
    PHP Code:
    function replace($string)
    {
     
    $pattern[0] = "{site_domain}";
     
    $pattern[1] = "{site_name}"
     
     
    $replacement[0] = "$site_domain";
     
    $replacement[1] = "$site_name"
     
     
    ksort($pattern);
     
    ksort($replacement);
     
     
    str_replace($pattern$replacement"$string");
     
     return 
    $string;

    Still wont replace the {site_domain} with its value -.-
    Why do you keep doing this? We have told you how to do it yet you refuse to listen.

  2. #12
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Sangreal View Post
    PHP Code:
    function replace($string)
    {
     
    $pattern[0] = "{site_domain}";
     
    $pattern[1] = "{site_name}"
     
     
    $replacement[0] = "$site_domain";
     
    $replacement[1] = "$site_name"
     
     
    ksort($pattern);
     
    ksort($replacement);
     
     
    str_replace($pattern$replacement"$string");
     
     return 
    $string;

    Still wont replace the {site_domain} with its value -.-
    Maybe if you listened to what we're trying to tell you it would.

    I dont see the point in this thread if your ignoring everything we suggest.
    Coming and going...
    Highers are getting the better of me

  3. #13
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    No need to enclose the $string in quotation marks.

  4. #14
    Join Date
    Dec 2006
    Location
    Kent, UK
    Posts
    627
    Tokens
    138
    Habbo
    Romanity

    Latest Awards:

    Default

    You actually havent suggested anything :S
    Sangreal / Romanity ~ Habbo UK & USA
    [OurHabbo.Net Owner]
    Lewis. (Formerly xRoyal15)

  5. #15
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Well maybe i was giving to much credit in assuming you knew how to correctly use a function as you appear to have ignored almost everything thats been said.. This example "Should" work.

    PHP Code:
    //Create all the vars
    $information "i like to eat {food} while drinking a glass of {drink}";
    $myfood "waffles";
    $mydrink "bleach";



    function 
    replace($string)
    {
     
    $pattern[0] = "{food}";
     
    $pattern[1] = "{drink}"
     
     
    $replacement[0] = $myfood;
     
    $replacement[1] = $myfrink
     
    $string str_replace($pattern$replacement$string);
     
     return 
    $string;
    }

    $information replace($information);
    echo 
    $information;

    *correct me if wrong i aint done php in ages
    Last edited by Mentor; 23-12-2007 at 06:18 PM.

  6. #16
    Join Date
    Dec 2006
    Location
    Kent, UK
    Posts
    627
    Tokens
    138
    Habbo
    Romanity

    Latest Awards:

    Default

    Thats the function i had anyway....

    Gets the info from the database... runs..

    $templateHTML = replace($nav[templateHTML]);
    echo "$templateHTML";

    But still doesnt change it... i dont think the problem is with the function .. out of the function it works, put it in a function and it breaks????
    Sangreal / Romanity ~ Habbo UK & USA
    [OurHabbo.Net Owner]
    Lewis. (Formerly xRoyal15)

  7. #17
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    You get $nav[templateHTML] how? Also you DO NOT need to inclose lone variables in quotation marks fgs. Just slows your script down.

  8. #18
    Join Date
    Dec 2006
    Location
    Kent, UK
    Posts
    627
    Tokens
    138
    Habbo
    Romanity

    Latest Awards:

    Default

    I get it with the query...
    The query works, because the template is echoed out, but it wont change the variables before it does...
    Sangreal / Romanity ~ Habbo UK & USA
    [OurHabbo.Net Owner]
    Lewis. (Formerly xRoyal15)

  9. #19
    Join Date
    May 2007
    Location
    Nebo, NC, USA
    Posts
    2,517
    Tokens
    0

    Latest Awards:

    Default

    fgs

    PHP Code:
    <?php

    //Create all the vars
    $information "i like to eat {food} while drinking a glass of {drink} then shopping in {store}";


    function 
    replace($string)
    {
        
    $myfood "waffles";
        
    $mydrink "bleach";
        
    $store "Wal-Mart";

        
    $find = array("{food}""{drink}""{store}");
        
    $replace = array($myfood$bleach$store);
        
    $string str_replace($find$replace$string);

        return 
    $string;
    }

    $information replace($information);
    echo 
    $information;


    ?>

  10. #20
    Join Date
    Dec 2006
    Location
    Kent, UK
    Posts
    627
    Tokens
    138
    Habbo
    Romanity

    Latest Awards:

    Default

    Thats what i got...
    PHP Code:
    function replace($string)
    {

     
    $pattern = array("{site_domain}""{site_name}"); 

     
    $replacement = array("$site_domain""$site_name"); 

     
    str_replace($pattern$replacement$string);

     return 
    $string;

    All variables are already defined.... but the function wont work... it physically does doesnt change it to anything. Your all saying the same thing, and im saying if you listen, its not working...
    Sangreal / Romanity ~ Habbo UK & USA
    [OurHabbo.Net Owner]
    Lewis. (Formerly xRoyal15)

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

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