Can someone help me decode why this is not working?
$cssid = preg_replace("/'/", "", $cssid);
Trying to strip single quote marks from some html ...
Thanks! N
EDIT This is a complete function - it is designed to restore Drupal menus using images, and it applies CSS classes to each element, allowing you to select the image you want. You need to remove spaces and apostrophes or CSS selector failure.
The name of the menu item causing this whole problem is the following:
What new
Pretty harmless as you think. (Except for this single)
function primary_links_add_icons() {
$links = menu_primary_links();
$level_tmp = explode('-', key($links));
$level = $level_tmp[0];
$output = "<ul class=\"links-$level\">\n";
if ($links) {
foreach ($links as $link) {
$link = l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment']);
$cssid = str_replace(' ', '_', strip_tags($link));
$cssid = str_replace('\'', '', $cssid);
$output .= '<li id="'.$cssid.'">' . $link .'</li>';
};
$output .= '</ul>';
}
return $output;
}
EDIT saga continues ...
I noticed that in PHPMYADMIN the following error occurs:
PHP mbstring , , . mbstring phpMyAdmin - .
, ?
SQL:
('primary-links', 951, 0, 'http://www.google.com', '', 'What' New',
FireBug :
<li id="What's_New">
"What @s New", str_replace() , . , , , . , , , , - PHP .
, - ...
, l(), , , ?! ...
function primary_links_add_icons() {
$links = menu_primary_links();
$level_tmp = explode('-', key($links));
$level = $level_tmp[0];
$output = "<ul class=\"links-$level\">\n";
if ($links) {
foreach ($links as $link) {
$link['title'] = str_replace('\'', '', $link['title']);
$link = l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment']);
$cssid = str_replace(' ', '_', strip_tags($link));
$output .= '<li id="'.$cssid.'">' . $link .'</li>';
};
$output .= '</ul>';
}
return $output;
}
2 ...
, drupal , , , .