...

View Full Version : Help me with php



sonic656
10-15-2011, 10:41 AM
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"......

Adee
10-15-2011, 10:57 AM
Do this:




$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:




echo $words[0]; // 'ps'
echo $words[1]; // 'xa'

// or

foreach ( $words as $pieces )
{
echo $pieces . "<br />";
}

sonic656
10-15-2011, 12:28 PM
thank you man! :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum