Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function create_css(&$tab){
- $all_values = [];
- if (!file_exists('style.css')) {
- for ($i = 0; $i < count($tab); $i++) {
- $tmp = getimagesize($tab[$i]);
- array_push($all_values, $tmp);;
- $path = explode("/", $tab[$i]);
- $path = end($path);
- $path =str_replace(".","_" ,$path );
- static $back_pos = 0;
- $height = "#" .$path. "{\n"."width :".$all_values[$i][0]."px;\n"
- ."height :".$all_values[$i][1]."px;\n"."display:inline-block;\n"
- ."background-repeat: no-repeat; \n"
- ."background-position: -" .$back_pos ." 0px; \n"
- ."background-image: url('sprite.png');" ."\n}" ."\n \n" ;
- $back_pos += $all_values[$i][0];
- file_put_contents('style.css', $height, FILE_APPEND);
- }
- }
- else if(file_exists('style.css')){
- unlink('style.css');
- create_css($tab);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement