Page 1 of 1
explode() not splitting string data
Posted: Fri Aug 04, 2006 12:26 pm
by Brent
I am using system('ipconfig', $output) to display the output in a browser window. $output displays as one continuous line since all the line breaks are stripped out so I am trying to break the data back up into a readable format using explode() but it doesn't split the string.
system('ipconfig', $output);
$ipconfig = explode(':',$output);
for($i=0;$i<count($ipconfig);$i++)
{
echo $ipconfig[$i] . "\n";
}
Thanks in advance.
Posted: Fri Aug 04, 2006 12:51 pm
by jayshields
I've been messing with this for 15 minutes now, mainly because I couldn't remember the HTML tag lol.
Code: Select all
<?php
echo '<pre>';
system('ipconfig');
echo '</pre>';
Never used system() before, what a weird function. It actually automatically prints the command results. If you try to set an output var to store the result, it sets the variable to 0.
You can't set a variable to the system() call properly either, as it only stores the last line of the result.
Seems it's impossible to use system() without getting some output.
So the answer to your question is, the output is already on seperate lines, you just couldn't see it because it wasn't proper HTML - check the source

Posted: Fri Aug 04, 2006 1:20 pm
by Brent
jayshields wrote:I've been messing with this for 15 minutes now, mainly because I couldn't remember the HTML tag lol.
Code: Select all
<?php
echo '<pre>';
system('ipconfig');
echo '</pre>';
Never used system() before, what a weird function. It actually automatically prints the command results. If you try to set an output var to store the result, it sets the variable to 0.
You can't set a variable to the system() call properly either, as it only stores the last line of the result.
Seems it's impossible to use system() without getting some output.
So the answer to your question is, the output is already on seperate lines, you just couldn't see it because it wasn't proper HTML - check the source

You are a lifesaver! Thank you! Works Perfectly! I have been fighting with this for days, Never used '<pre>' before. I was about to resort to redirecting to a txt file and using iframe to display it.