用PHP获取Java Println输出

I'm trying to get the output from a java application that would use the below code to output values

System.out.println(object.getNumber(3));
System.out.println(object.getNumber(4));

I'm using exec("somejavapath javaName", $output) and print_r($output) to get that output array to print. I know it will get the values but I wanted to get into a certain format So instead of

Array
(
[0] => 34
)

I want something like this

Array
(
[0] => 3
[1] => 4
)

Does anyone know what I could do to get this format?

Thanks

If you are not expecting comas in the output from java application , include a coma between the two values :

System.out.println(object.getNumber(3));
System.out.println(",");    // Print a coma in between
System.out.println(object.getNumber(4));

Then

$values_array = explode( ',', $output );

You can use explode to break the content up using a delimiter, in this case, a line-break ().

$var = explode('
', $output); // split output by line breaks