SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Aug 2000
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    im working on a formatter...

    It is for an online game that i play, where you see a screen that tells you, how good you are, ect. It is called a "clear sight"


    This is what my screen looks like...

    ----------

    The Dominion of One Man Army (# 255)
    Overview
    Ruler: Lord Sven
    Race: Wood Elf
    Land: 2,863
    Peasants: 35,509
    Draftees: 0
    Employment: 100%
    Networth: 241,198
    Resources
    Platinum: 469
    Food: 73,420
    Lumber: 38,733
    Mana: 11,284
    Ore: 411
    Gems: 0
    Boats: 216
    Military
    Morale: 60%
    Rangers: 0
    Longbowmen: 0
    Mystics: 15,604
    Druids: 962
    Spies: 5,175
    Wizards: 0
    ArchMages: 120

    -------------

    Now.. i think to myself, how would i be able to make this information... and make it into something usefull...

    So this is what i am thinking..

    PAGE 1
    INPUT PAGE

    <form method="POST" action="calculate.php">
    <textarea rows="2" name="input" cols="20">
    </textarea>
    <input type="submit" value="Submit" name="submit">
    </form>


    PAGE 2
    SAVE THE FILE

    <?
    // This Clearsite will be saved to
    $filename = "CS/1.php";

    // Handle to open the file and in what mode
    $handle= fopen($filename,'a+');

    // The input will be given the variable name post
    $post ="$input";

    // Opens the file then writes the Clear sight in.
    fputs($handle, $post);

    // close the clearsight
    fclose($handle);

    ?>

    PAGE 3
    Read And Manipulate Data

    This is where i am stumped, i need a way to get the information i need out of the inputed data..

    $Province_name= "One Man Army (# 255)";
    $ruler= "Lord Sven";
    $race= "Wood Elf";

    Now i know i can use substr() to get the info i want,

    what i was wondering, is there any way i could search 5 lines down and go,


    $race= substr(stuff on this line ,6);

    im pretty confused, if anyone could help me that would be great

    I remember falling...
    i remember marching..
    like a one man army..


  2. #2
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I can't say I completely understand what you're trying to do, but I can tell you it would be much easier to do with a database.

    Failing that, try the file() function, which lets you read a file into a PHP array, with each element in the array being the contents of a line in the file. Thus, the 5th line of the file can be accessed as arrayName[4].
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference


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
  •