gordon.c Posted July 2, 2010 Share Posted July 2, 2010 hi, these two functions preg_replace() and trim() work fine on my virtual apache server however they dont work online on the webhosting server. What could be the issue. Is it the version of PHP? My virtual server runs php 4.4.9 the webhosting runs probably the latest possible 5.something. Or is there some setting in .htaccess I shall do, to make it work? Thank you for help Link to comment https://forums.phpfreaks.com/topic/206551-preg_replace-and-trim/ Share on other sites More sharing options...
AbraCadaver Posted July 2, 2010 Share Posted July 2, 2010 hi, these two functions preg_replace() and trim() work fine on my virtual apache server however they dont work online on the webhosting server. What could be the issue. Is it the version of PHP? My virtual server runs php 4.4.9 the webhosting runs probably the latest possible 5.something. Or is there some setting in .htaccess I shall do, to make it work? Thank you for help What do you mean they don't work? Care to post some code and the results? Link to comment https://forums.phpfreaks.com/topic/206551-preg_replace-and-trim/#findComment-1080400 Share on other sites More sharing options...
gordon.c Posted July 2, 2010 Author Share Posted July 2, 2010 Very familiar method that simply strips a string off dangerous characters. (For creating nice looking URLs) <?php function RemoveMultibyte($text) { $new = $text; $new = preg_replace('~[^\\pL0-9_]+~u', '-', $new); $new = trim($new, "-"); $new = strtolower($new); $new = preg_replace('~[^-a-z0-9_]+~', '', $new); return $new; } ?> Input: píča kunda Output: pa-kunda On my virtual machine, it would do its work correctly, replace blanks for dashes, remove any non-english chars.... On hosting server this same function will not return any output at all. Link to comment https://forums.phpfreaks.com/topic/206551-preg_replace-and-trim/#findComment-1080420 Share on other sites More sharing options...
AbraCadaver Posted July 2, 2010 Share Posted July 2, 2010 What does this produce: function RemoveMultibyte($text) { $new = $text; echo $new . '<br>'; $new = preg_replace('~[^\\pL0-9_]+~u', '-', $new); echo $new . '<br>'; $new = trim($new, "-"); echo $new . '<br>'; $new = strtolower($new); echo $new . '<br>'; $new = preg_replace('~[^-a-z0-9_]+~', '', $new); echo $new . '<br>'; return $new; } Link to comment https://forums.phpfreaks.com/topic/206551-preg_replace-and-trim/#findComment-1080423 Share on other sites More sharing options...
gordon.c Posted July 3, 2010 Author Share Posted July 3, 2010 For input " piča kunda " Virtual server returns pica kunda pica-kunda pica-kunda pica-kunda pica-kunda Hosting server returns pica kunda p- p p p Link to comment https://forums.phpfreaks.com/topic/206551-preg_replace-and-trim/#findComment-1080605 Share on other sites More sharing options...
gordon.c Posted July 3, 2010 Author Share Posted July 3, 2010 any idea what might have gone wrong? Link to comment https://forums.phpfreaks.com/topic/206551-preg_replace-and-trim/#findComment-1080830 Share on other sites More sharing options...
gordon.c Posted July 6, 2010 Author Share Posted July 6, 2010 are there maybe any equivalent functions that would do the same thing? I still didnt figure it out Link to comment https://forums.phpfreaks.com/topic/206551-preg_replace-and-trim/#findComment-1081782 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.