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!


Results 1 to 5 of 5

Thread: [+rep] PHP Help

  1. #1
    Join Date
    Feb 2008
    Location
    London, UK
    Posts
    15,747
    Tokens
    25,786
    Habbo
    Mr-Trainor

    Latest Awards:

    Arrow [+rep] PHP Help

    Ok, so earlier this year I made this page (with the help of a tutorial I found online and just playing around with it and editing it) and basically what I'm trying to do is make a page where you can find new catalogue icons uploaded to Habbo. So here's what it is at the moment: (or click here to see how it looks, i.e. the layout of it)

    Code:
    <?php
    
    
    $handle = opendir(dirname(realpath(__FILE__)).'/directory/');
            while($file = readdir($handle)){
                if($file !== '.' && $file !== '..'){
                    echo '<img src="http://images.habbo.com/c_images/catalogue/'.$file.'" border="0" /> '.$file.'<br />';
                }
            }
    ?>
    But what I want to do is order them so that they show up in order of their number, i.e. 1,2,3... 178,179 and so on. So if anyone can help with that, it'd be much appreciated ! I have very little knowledge of PHP and everything I've tried has failed .

    Not online very often

  2. #2
    Join Date
    May 2007
    Posts
    10,481
    Tokens
    3,140

    Latest Awards:

    Default

    Rather than echoing them add them to an array by their number and then iterate through the array.
    Chippiewill.


  3. #3
    Join Date
    Feb 2008
    Location
    London, UK
    Posts
    15,747
    Tokens
    25,786
    Habbo
    Mr-Trainor

    Latest Awards:

    Default

    Quote Originally Posted by Chippiewill View Post
    Rather than echoing them add them to an array by their number and then iterate through the array.
    Thanks, I'll play around with it tomorrow and see if I can get it to work .

    Not online very often

  4. #4
    Join Date
    Feb 2008
    Location
    London, UK
    Posts
    15,747
    Tokens
    25,786
    Habbo
    Mr-Trainor

    Latest Awards:

    Default

    I got rid of what I had before, and just came up with this:

    Code:
    <?php
    
    $number=array("1","2","3","4","5","6","7","8","9","10");
    $arrlength=count($number);
        for($x=0;$x<$arrlength;$x++)
                {
                echo '<img src="http://images.habbo.com/c_images/catalogue/icon_' . $number[$x] . '.png" border="0" /> icon_' . $number[$x] . '.png<br />';
                }
            
    ?>
    Is there a quicker way to add all numbers 1-200 ?

    ---------- Post added 16-03-2013 at 11:13 AM ----------

    Ok nevermind, I managed to do it like this:

    Code:
    <?php
    
    foreach (range(1, 200) as $number) {
    	echo '<img src="http://images.habbo.com/c_images/catalogue/icon_' . $number . '.png" border="0" /> icon_' . $number . '.png<br />';
    			}
    		
    ?>

    Not online very often

  5. #5
    Join Date
    Mar 2013
    Posts
    4
    Tokens
    16

    Default

    PHP Code:
    <?php
        
    for( $i 1$i <= 200$i++ ) {
            echo 
    "<img src=\"http://images.habbo.com/c_images/catalogue/icon_{$i}.png\" border=\"0\" /> icon_{$i}.png<br />";
        }
    ?>
    I think you should be able to understand why. It's much simpler this way.
    @Mr-Trainor

Posting Permissions

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