Reputation: 1805
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
Upvotes: 0
Views: 592
Reputation: 2492
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 );
Upvotes: 1
Reputation: 77074
You can use explode
to break the content up using a delimiter, in this case, a line-break (\n
).
$var = explode('\n', $output); // split output by line breaks
Upvotes: 0