clanstyles Posted July 23, 2007 Share Posted July 23, 2007 I have this code. <?php include("config.php"); //exec("du -s *", $output); $output = file("data.php", "r"); $var = arraytostring($output); //$newoutput = explode("\t", $var); $newoutput = explode("\n\t", $var); $date = date("mm/d/y"); for($a=0;$a < count($newoutput);$a += 2) { if($a % 2) { $dir = $newoutput[$a]; $size = $newoutput[$a+1]; echo "Size: " . $size . "<br />"; echo "Dir: " . $dir . "<br />"; } else { $dir = $newoutput[$a+1]; $size = $newoutput[$a]; echo "Size: " . $size . "<br />"; echo "Dir: " . $dir . "<br />"; } //if(!is_file($dir)) //mysql_query("INSERT INTO `serverInfo` ( `id` , `serverid` , `size` , `filename` , `timestamp` ) VALUES('null', '1', '$size', '$dir', '06/25/07')") or die(mysql_error()); } function arraytostring($array) { $count=count($array); foreach ($array as $key=>$value) { $x++; if (is_array($value)) { if(substr($text,-1,1)==')') $text .= ','; $text.='"'.$key.'"'."=>".arraytostring($value); continue; } $text.=$value; if ($count!=$x) $text.="\t"; } if(substr($text, -4, 4)=='),),')$text.='))'; return $text; } ?> Whats happening is that It isan't seeing the difference between the [tab] spacing. its four spaces. thanks Link to comment https://forums.phpfreaks.com/topic/61409-file-io-and-formating/ Share on other sites More sharing options...
clanstyles Posted July 27, 2007 Author Share Posted July 27, 2007 bump Link to comment https://forums.phpfreaks.com/topic/61409-file-io-and-formating/#findComment-308896 Share on other sites More sharing options...
clanstyles Posted July 27, 2007 Author Share Posted July 27, 2007 bump. Link to comment https://forums.phpfreaks.com/topic/61409-file-io-and-formating/#findComment-308995 Share on other sites More sharing options...
clanstyles Posted July 27, 2007 Author Share Posted July 27, 2007 bump Link to comment https://forums.phpfreaks.com/topic/61409-file-io-and-formating/#findComment-309271 Share on other sites More sharing options...
clanstyles Posted August 2, 2007 Author Share Posted August 2, 2007 bump Link to comment https://forums.phpfreaks.com/topic/61409-file-io-and-formating/#findComment-314054 Share on other sites More sharing options...
premiso Posted August 2, 2007 Share Posted August 2, 2007 Fourspaces sucks you can try and convert all 4 spaces into tabs. <?php $var = str_replace(" ", "\t", $file); $newoutput = explode("\n\t", $var); ?> But that is flawed in its own sense too. If you are expecting tabs but are getting 4 spaces, sounds like you need to fix the original file. Link to comment https://forums.phpfreaks.com/topic/61409-file-io-and-formating/#findComment-314167 Share on other sites More sharing options...
clanstyles Posted August 2, 2007 Author Share Posted August 2, 2007 THANK YOU FOR SAYING THAT YES!!! Sorry I needed somebody to say that to show my boss ( Its free work but still ). Link to comment https://forums.phpfreaks.com/topic/61409-file-io-and-formating/#findComment-314210 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.