Q:

php filter strings before and after specific word with varied lengths

I have a string similar to this....
$string = "order apples oranges pears and bananas from username";

How can I get it into something like this?
$products = "apples oranges pears and bananas";
$username = "username";

A:

list($products,$username) = explode("from", $string);

A:

$string = "order apples oranges pears and bananas from username";
list($products,$username) = explode(" from ", $string);
$products = str_replace('order ', '', $products);

//print results for verification
var_dump(array($products,$username));

outputs:
array(2) { [0]=> string(32) "apples oranges pears and bananas" [1]=> string(8) "username" }

but this will not handle different "commands" other than "order" and also assumes all whitespace between words is a single space character.  You need more complex code to handle multiple cases, but that would require more information from you.

