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 Coder
    Join Date
    Sep 2011
    Location
    127.0.0.1
    Posts
    62
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Help me with php

    Hi. I want to make a console such as the linux console, but I don't know how to do that: when someone writes "ps xa" php will divide that string into words: word number 1 into string "word1", word number 2 into string "word2"......

  • #2
    Regular Coder
    Join Date
    Jul 2010
    Location
    Oregon City
    Posts
    280
    Thanks
    5
    Thanked 50 Times in 49 Posts
    Do this:

    Code:
    $yourCommand = "ps xa";
    
    $words = explode(" ", $yourCommand);
    $words is an array consisting of 2 elements: ps and xa.

    You can access each of them by doing:

    Code:
    echo $words[0]; // 'ps'
    echo $words[1]; // 'xa'
    
    // or
    
    foreach ( $words as $pieces )
    {
       echo $pieces . "<br />";
    }

  • Users who have thanked Adee for this post:

    sonic656 (10-15-2011)

  • #3
    New Coder
    Join Date
    Sep 2011
    Location
    127.0.0.1
    Posts
    62
    Thanks
    18
    Thanked 0 Times in 0 Posts
    thank you man!


  •  

    Posting Permissions

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