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.
explode() not splitting string data
Moderator: General Moderators
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
I've been messing with this for 15 minutes now, mainly because I couldn't remember the HTML tag lol.
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
Code: Select all
<?php
echo '<pre>';
system('ipconfig');
echo '</pre>';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.jayshields wrote:I've been messing with this for 15 minutes now, mainly because I couldn't remember the HTML tag lol.
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.Code: Select all
<?php echo '<pre>'; system('ipconfig'); echo '</pre>';
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