Jump to content

preg_replace


codingmasterRS

Recommended Posts

index.php

$file = file_get_contents('fg.menu.css');
echo preg_replace('', $file);

 

fg.menu.css

/* Styles for jQuery menu widget
Author:	Maggie Wachs, maggie@filamentgroup.com
Date:		September 2008
*/


/* REQUIRED STYLES - the menus will only render correctly with these rules */	

.nav-menu-container { position: absolute; top:0; left:-999px; padding: .4em;  overflow: hidden; }
.nav-menu-container.nav-menu-flyout { overflow: visible; }

.nav-menu, .nav-menu ul { list-style-type:none; padding: 0; margin:0; }

.nav-menu { position:relative; }
.nav-menu-flyout .nav-menu { position:static; }

.nav-menu ul { position:absolute; top:0; }
.nav-menu ul ul { top:-1px; }

.nav-menu-container.nav-menu-ipod .nav-menu-content, 
.nav-menu-container.nav-menu-ipod .nav-menu-content ul { background: none !important; }

.nav-menu.nav-menu-scroll,
.nav-menu ul.nav-menu-scroll { overflow: scroll;  overflow-x: hidden; }

.nav-menu li { clear:both; float:left; width:100%; margin: 0; padding:0; border: 0; }	
.nav-menu li li { font-size:1em; } /* inner li font size must be reset so that they don't blow up */

.nav-menu-flyout ul ul { padding: .4em; }
.nav-menu-flyout li { position:relative; }

.nav-menu-scroll { overflow: scroll; overflow-x: hidden; }

.nav-menu-breadcrumb { margin: 0; padding: 0; }

.nav-menu-footer {  margin-top: .4em; padding: .4em; }
.nav-menu-header {  margin-bottom: .4em; padding: .4em; }

.nav-menu-breadcrumb li { float: left; list-style: none; margin: 0; padding: 0 .2em; font-size: .9em; opacity: .7; }
.nav-menu-breadcrumb li.nav-menu-prev-list,
.nav-menu-breadcrumb li.nav-menu-current-crumb { clear: left; float: none; opacity: 1; }
.nav-menu-breadcrumb li.nav-menu-current-crumb { padding-top: .2em; }

.nav-menu-breadcrumb a, 
.nav-menu-breadcrumb span { float: left; }

.nav-menu-footer a:link,
.nav-menu-footer a:visited { float:left; width:100%; text-decoration: none; }
.nav-menu-footer a:hover,
.nav-menu-footer a:active {  }

.nav-menu-footer a span { float:left; cursor: pointer; }

.nav-menu-breadcrumb .nav-menu-prev-list a:link,
.nav-menu-breadcrumb .nav-menu-prev-list a:visited,
.nav-menu-breadcrumb .nav-menu-prev-list a:hover,
.nav-menu-breadcrumb .nav-menu-prev-list a:active { background-image: none; text-decoration:none; }

.nav-menu-breadcrumb .nav-menu-prev-list a { float: left; padding-right: .4em; }
.nav-menu-breadcrumb .nav-menu-prev-list a .nav-menu-uiicon { float: left; }

.nav-menu-breadcrumb .nav-menu-current-crumb a:link,
.nav-menu-breadcrumb .nav-menu-current-crumb a:visited,
.nav-menu-breadcrumb .nav-menu-current-crumb a:hover,
.nav-menu-breadcrumb .nav-menu-current-crumb a:active { display:block; background-image:none; font-size:1.3em; text-decoration:none; }



/* REQUIRED LINK STYLES: links are "display:block" by default; if the menu options are split into 
selectable node links and 'next' links, the script floats the node links left and floats the 'next' links to the right	*/

.nav-menu a:link,
.nav-menu a:visited,
.nav-menu a:hover,
.nav-menu a:active { float:left; width:92%; padding:.3em 3%; text-decoration:none; outline: 0 !important; }

.nav-menu a { border: 1px dashed transparent; }

.nav-menu a.nav-menu-uistate-default:link,
.nav-menu a.nav-menu-uistate-default:visited,
.nav-menu a.nav-menu-uistate-default:hover,
.nav-menu a.nav-menu-uistate-default:active,
.nav-menu a.nav-menu-uistate-hover:link,
.nav-menu a.nav-menu-uistate-hover:visited,
.nav-menu a.nav-menu-uistate-hover:hover,
.nav-menu a.nav-menu-uistate-hover:active,
.nav-menu a.nav-menu-uistate-active:link,
.nav-menu a.nav-menu-uistate-active:visited,
.nav-menu a.nav-menu-uistate-active:hover,
.nav-menu a.nav-menu-uistate-active:active { border-style: solid; font-weight: normal; }

.nav-menu a span { display:block; cursor:pointer; }


/* SUGGESTED STYLES - for use with jQuery UI Themeroller CSS */	

.nav-menu-indicator span { float:left; }
.nav-menu-indicator span.nav-menu-uiicon { float:right; }

.nav-menu-content.nav-menu-uiwidget-content, 
.nav-menu-content ul.nav-menu-uiwidget-content { border:0; }


/* ICONS AND DIVIDERS */

.nav-menu.nav-menu-has-icons a:link,
.nav-menu.nav-menu-has-icons a:visited,
.nav-menu.nav-menu-has-icons a:hover,
.nav-menu.nav-menu-has-icons a:active { padding-left:20px; }

.nav-menu .horizontal-divider hr, .nav-menu .horizontal-divider span { padding:0; margin:5px .6em; }
.nav-menu .horizontal-divider hr { border:0; height:1px; }
.nav-menu .horizontal-divider span { font-size:.9em; text-transform: uppercase; padding-left:.2em; }

 

 

So it should remove all the comments (the stuff between /* and */)

 

Then it needs to get all the stuff between { and } and number to an array relative to their tag, so:

.nav-menu-container = $tag[1]

and

position: absolute; top:0; left:-999px; padding: .4em;  overflow: hidden; = $contents[1]

 

etc

 

Thanks

 

Link to comment
Share on other sites

Despite the obnoxious bumping, here is workable code:

 

$file = file_get_contents('fg.menu.css');
$file = preg_replace('#/\*.*?\*/#s', '', $file);

preg_match_all('#(\b[^{]+){[^}]+}#', $file, $tag);
$tag = $tag[1];

preg_match_all('#{([^}]+)}#', $file, $content);
$content = $content[1];

print_r($tag);
print_r($content);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.