Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Xp Calculator - Converting Levels to Xp

    Okay, I'm new to PHP coding...I'm creating a simple experience calculator for a game - I have the basic coding down, but I need to know how to convert the level given, into experience. My arrays are set up as follows:

    $level = array (
    array ( xp="0",
    level=>"1",
    array ( xp="83",
    level=>"2",
    array ( xp="176",
    level=>"3",

    and etc...Is it possible to have the input point to a certain array in the set to change the input to experience, or do I need to do something else?

    ~The Fant

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,108
    Thanks
    11
    Thanked 101 Times in 99 Posts
    I dont really know what you want to do so this is probably not relevant to your problem .. eg calculator ? what are we calculating ?

    for display this may work though.

    PHP Code:
    <?php

    $level 
    =array(
        
    1=>array('xp'=>'label'=>'zip diddly') ,
        
    2=>array('xp'=>83 'label'=>'apprentice yak') ,
        
    3=>array('xp'=>176 'label'=>'oodles') ,
        
    4=>array('xp'=>10000 'label'=>'spooksteresque')
        );

    $selected ;

    echo 
    'experience required for level ' 
           
    $selected .' ( '$level[$selected]['label'] .' ) = ' 
           
    .$level[$selected]['xp'
           ;
    ?>
    Last edited by firepages; 09-24-2003 at 07:10 AM.
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #3
    New to the CF scene
    Join Date
    Sep 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Actually, that does help. O_o

    Thanks!

    ~The Fant


  •  

    Posting Permissions

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