Remove All Special Characters And Replace Spaces..

I have a PHP function to covert certain text to lowercase, remove special characters and replace space with hyphens.
I want to place them in some modules to create a link to images from the category name.

For example Modzzz Meet Me module.

Now the URL formed from the category is .../special-icons/Play.png or .../special-icons/Listen / Watch.png
It must be .../special-icons/play.png or .../special-icons/listen-watch.png

Below the function:

function clean($string) {

$string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens.

$string = preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.

$string = strtolower($string); // Convert to lowercase

 

return $string;



I have some trouble placing this inside the current code and make it work only for that line.

Below the code (from in this case Modzzz) with the key to show the meeting type. I marked the line that we try to change in yellow.

...
 $aAuthor = getProfileInfo($aData['author_id']); 

$sOwnerThumb = $GLOBALS['oFunctions']->getMemberThumbnail($aAuthor['ID'], 'left'); 

  

$iLimitChars = (int)getParam('modzzz_meeting_message_length');

    

        $aVars = array (   

'id' => $aData['id'],

            'post_uthumb' => $sOwnerThumb,

'meeting_url' => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/' . $aData['uri'],

'meeting_title' => $aData['title'],

'country_city' => _t($GLOBALS['aPreValues']['Country'][$aData['country']]['LKey']) . (trim($aData['city']) ? ', '.$aData['city'] : ''),

 

'meeting_date' => date('d F', $aData['when']),

 

'meeting_type' => $this->parsePreValues ('MeetType', $aData['meet_type']),
... 

Hopefully someone knows what to change. I tried it a couple of times, but I get a totally blank screen of everything appears, but it has no effect. 

Quote · 21 Dec 2014

Anyone?

Quote · 23 Dec 2014

For the particular example you use, the MeetType is a predefined list. You modify this by logging into Admin then go to Settings => Predefined Values and look for "MeetType" in the drop-down list.

Paypal email is jeromemingo@gmail.com - http://www.boonex.com/market/posts/modzzz
Quote · 31 Dec 2014

 Yes, I know. But normally with adding a category you add a capital first letter. For example one of our meeting types is "Eat". Because we show the word "Eat" it needs to still be with a capital "E".

However when we load the category as part of a link to the icon that needs to appear next to the Category in words, it needs to be without special characters, spaces and complete lowercase. For example now the link to an image is "background-image:url(http://heavn.lab43.nl/special-icons/dates/__meeting_type__.png);

Another category is Listen / Watch. If you place that in a link to an image it's not possible. That's why we need to remove special characters, spaces and make it lowercase.

For the particular example you use, the MeetType is a predefined list. You modify this by logging into Admin then go to Settings => Predefined Values and look for "MeetType" in the drop-down list.

 

Quote · 31 Dec 2014

The same with the places module...

We've made an shortcode for the category icon:
'heavn_categories_icon' => 'http://heavn.lab43.nl/special-icons/'.$aCategory['name'].'.png',

Now we need a way to remove spaces, special caracters and lowercase the category's.

For the particular example you use, the MeetType is a predefined list. You modify this by logging into Admin then go to Settings => Predefined Values and look for "MeetType" in the drop-down list.

 

Quote · 2 Jan 2015
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.