File: _2totab.php

Recommend this page to a friend!
  Classes of Joseph  >  JS Master Color Picker script  >  _2totab.php  >  Download  
File: _2totab.php
Role: Auxiliary data
Content type: text/plain
Description: file-system converter tool
Class: JS Master Color Picker script
Pick colors from a palette
Author: By
Last change:
Date: 7 years ago
Size: 1,192 bytes


Class file image Download

<?php /*  2totab.php
	take all script files in the folder that contains this file, AND it’s subfolders,
	and convert all double spaces at line beginnings to tabs
	and clean up stray whitespace at line ends  */


function opener($folder)  { $types=array('.php', '.js', '.css', '.htm');  global $totalSaved;
	while ($F=readdir($D))  {  if ($F=='.' or $F=='..')  continue;
		if (is_dir($folder.$F))  {opener($folder.$F."\\");  continue;}
		if (!in_array(strrchr($F, '.'), $types))  continue;
		$f1=file_get_contents($folder.$F);  $size=strlen($f1);
		preg_match('/(\r\n|\n|\r)/', $f1, $lb);
		$f1=explode($lb[0], $f1);
		foreach ($f1 as &$l)  {
				$l );
				'/^[ \t]+/',
				function($m) {return preg_replace(array('/  /', '/ \t/'), "\t", $m[0]);},
				$l );  }
		$f1=implode($lb[0], $f1);
		$saved=$size-strlen($f1);  $totalSaved+=$saved;
		if ($saved!=0)  file_put_contents($folder.$F, $f1);
		echo "<tr><td>",$saved,"</td><td>",$folder,$F,"</td></tr>\n";  }
echo "</table>\ntotal saved: ",$totalSaved;