View Full Version : Help me with php

10-15-2011, 11: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"......

10-15-2011, 11: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 />";

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