I have this script working to print specific contents of a tab delimited file to the screen.
So it reads a line, delimits it, and collects 3 pieces of information then goes to the next line.
Is it possible to sort the entire outcome by Name (the If($counter == 1) bit of info)?
That way when it prints to the screen, it will have the name, sql, and web info shown in alphabetical order.
I was thinking that it could be added to an array, though how do you know what size the array is going to be, and when you sort the array how to do you tell it to only sort by Name?
Code: Select all
<?php
$lines = file('c:\dwagent\clients.dwa');
foreach ($lines as $line_num => $line) {
$delimiter = "]";
$splitcontents = explode($delimiter, $line);
$counter = "";
?>
<br><br>
<?php
foreach ( $splitcontents as $color )
{
$counter = $counter+1;
If ($counter == 1){
echo "<b>Name: </b> $color <br>";
}
If ($counter == 3){
echo "<b>SQL: </b> $color <br>";
}
If ($counter == 5){
echo "<b>WEB: </b> $color <br>";
}
}
}
?>