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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Feb 2006
    Posts
    262
    Thanks
    23
    Thanked 1 Time in 1 Post

    Post Make array with txt file content

    Good day to you all,
    Here is a piece of code from my login script.

    PHP Code:

    $data
    =array("user1"=>array("url"=>"Index/admin-index.php","password"=>"pass1"),
                
    "user2"=>array("url"=>"file2.php","password"=>"pass2")); 
    As you can see the array is not a generated array, in other word, the script should read a txt file, each line would have, a password, username and a url.
    like :
    Jack=>Daniel=>Director/index.php
    Angolina=>Joli=>Pretty/index.php
    Mike=>Lee=>User/index.php

    Thanks !
    Franck

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,472
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    If your textfile (called "test.txt") looks like this:
    Jack|Daniel|Director/index.php
    Angolina|Joli|Pretty/index.php
    Mike|Lee|User/index.php


    PHP Code:
    <?php

    $data 
    file("test.txt");

    foreach(
    $data as $value){
    list (
    $pass$user$url) = split ('\|'$value);
    echo 
    "$value<br />\n";
    echo 
    "Password:$pass  User:$user  URL:$url <br /><br />";
    }
    ?>


  •  

    Posting Permissions

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