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 10 of 10

Thread: PHP to .txt

  1. #1
    Join Date
    Sep 2007
    Posts
    56
    Tokens
    0

    Default PHP to .txt

    If I had the time I could write this script myself but I am looking for a way to create a .txt file with 4 digit numbers in it. however the numbers are all dynamically created. It would need every single 4 digit number there is.

    Moved by Jamesy (Forum Moderator): From "Technology Discussion" - Please post in the correct forum in future.
    Last edited by Jamesy; 13-09-2009 at 01:57 PM.

  2. #2
    Join Date
    Jun 2008
    Location
    United Kingdom
    Posts
    2,015
    Tokens
    568

    Latest Awards:

    Default

    So you want a .txt file with every number from 1000-9999 (or 0000-9999, whatever)?

    Quote Originally Posted by Dromenail View Post
    If I had the time I could write this script myself
    It would have taken less time to write the script than it took to create this thread.

  3. #3
    Join Date
    Sep 2007
    Posts
    56
    Tokens
    0

    Default

    from 0000 and every other combination upwards.

  4. #4
    Join Date
    Apr 2009
    Location
    United Kingdom
    Posts
    1,111
    Tokens
    100

    Latest Awards:

    Default

    Quote Originally Posted by Trinity View Post
    It would have taken less time to write the script than it took to create this thread.
    Why didn't you help him then instead of just moaning?

    Txt file:
    http://www.zshare.net/download/65565576dca3208c/

    PHP File:
    PHP Code:
    <?php

    $startNumber 
    0000;

    while (
    $startNumber <= 9999){

    if (
    strlen($startNumber) == 1){

    echo 
    '000'.$startNumber.'<br>';

    }else if (
    strlen($startNumber) == 2){

    echo 
    '00'.$startNumber.'<br>';

    }else if(
    strlen($startNumber) == 3){

    echo 
    '0'.$startNumber.'<br>';

    }else{

    echo 
    $startNumber.'<br>';

    }


    $startNumber++;


    ?>
    The php script is awful but it works. I couldn't remember the way to number format. Oh well, I wrote it super quick and nobody else offered to help so umm there you go I suppose.

  5. #5
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    PHP Code:
    <?php

    for( $i 0$i <= 9999$i++ ) {
        
        echo 
    $i '<br />';

    }

    ?>
    Modify it to write to a file instead.

  6. #6
    Join Date
    Jun 2008
    Location
    United Kingdom
    Posts
    2,015
    Tokens
    568

    Latest Awards:

    Default

    Quote Originally Posted by BoyBetterKnow View Post
    Why didn't you help him then instead of just moaning?
    He didn't say please, that's just rude. And I wasn't moaning, I was stating a fact

    @Invent you'd also need to format the numbers so they're 4 digits long (0001 etc.)
    Last edited by Trinity; 14-09-2009 at 07:51 PM.

  7. #7
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    Quote Originally Posted by Trinity View Post
    He didn't say please, that's just rude. And I wasn't moaning, I was stating a fact

    @Invent you'd also need to format the numbers so they're 4 digits long (0001 etc.)
    Oh, never realised that he wanted it to be 0000. Use this instead then:

    PHP Code:
    <?php

    for( $i 0$i <= 9999$i++ ) {
        
        echo 
    sprintf'%04d'$i ) . '<br/>';

    }

    ?>

  8. #8
    Join Date
    Apr 2009
    Location
    United Kingdom
    Posts
    1,111
    Tokens
    100

    Latest Awards:

    Default

    [QUOTE=Trinity;6053752]He didn't say please, that's just rude. And I wasn't moaning, I was stating a fact

    Okay sorry.

    Quote Originally Posted by Invent View Post
    Oh, never realised that he wanted it to be 0000. Use this instead then:

    PHP Code:
    <?php

    for( $i 0$i <= 9999$i++ ) {
        
        echo 
    sprintf'%04d'$i ) . '<br/>';

    }

    ?>
    Yeh much more efficient than mine

  9. #9
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default

    Hi,

    PHP Code:
    <?php
    $i 
    0;
    $fHandle = @fopen'file.txt''a' );

    if( 
    $fHandle === false ) { exit( 'check permissions.' ); }
    do {
        
    fwrite$fHandlesprintf'%04d'$i ) . "\n" );
        
    $i++;
    } while( 
    $i <= 9999 );

    fclose$fHandle );
    ?>
    Bye.

    P.S,
    PHP Code:
    <?php
    abstract class hWorldAbstraction
    {    
        public static function 
    run$incomingClass )
        {
            
    $incomingClass = new $incomingClass();
        }
        
        public function 
    __construct()
        {
            
    $this->_doHelloWorld();
        }
        
        abstract protected function 
    _doHelloWorld();
    }

    class 
    helloWorld extends hWorldAbstraction
    {
        protected function 
    _doHelloWorld()
        {
            echo 
    'Hello world!';
            exit(
    0);
        }
    }

    helloWorld::run'helloWorld' );
    ?>


    visit my internet web site on the internet
    http://dong.engineer/
    it is just videos by bill wurtz videos you have been warned

  10. #10
    Join Date
    Sep 2007
    Posts
    56
    Tokens
    0

    Default

    Quote Originally Posted by Jewish Bear View Post
    PHP Code:
    <?php
    abstract class hWorldAbstraction
    {    
        public static function 
    run$incomingClass )
        {
            
    $incomingClass = new $incomingClass();
        }
        
        public function 
    __construct()
        {
            
    $this->_doHelloWorld();
        }
        
        abstract protected function 
    _doHelloWorld();
    }

    class 
    helloWorld extends hWorldAbstraction
    {
        protected function 
    _doHelloWorld()
        {
            echo 
    'Hello world!';
            exit(
    0);
        }
    }

    helloWorld::run'helloWorld' );
    ?>
    rofl why.. thanks for the other script though

Posting Permissions

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