I am using
ps -l -u user
to get the running processes of a given user.
Now, when I want to split the information into arrays in PHP I am in trouble because ps
outputs the data for humans to read without fixed delimiters. So you can't split with space or tab as regex.
So far I can only detect the columns by character positions.
Is there any way in php to split a string into an array at certain positions? Something like:
$array=split_columns($string, $positions=array(1, 10, 14))
to cut a string into pieces at positions 1, 10 and 14?