zxf/css/parse.php

23 lines
485 B
PHP
Raw Normal View History

2023-10-11 21:42:06 +08:00
<?php
$file = './style.less.bak';
$newfile = './style.less';
$fp = fopen($file, 'a+');
$newfp = fopen($newfile, 'a+');
while (!feof($fp)) {
$line = fgets($fp);
$t = preg_replace_callback("/ (\d+)px/", function ($item) {
return ' ' . ($item[1] * 1) / 100 . 'rem';
}, $line);
fwrite($newfp, $t);
// print_r($t);
// preg_match_all("/ (\d+)px/", $line, $temp_matches, PREG_OFFSET_CAPTURE);
// print_r($temp_matches);
}
fclose($fp);
fclose($newfp);