string - PHP - Function to skip strtolower() if variable contain "wikipedia.org" -


My site allows users to enter URLs into a database. I am using the "$ site = strtolower ($ site)" code; "To make all these URLs lower-case.

However, I realized that the Wikipedia URL case is sensitive, so I want to avoid using" $ site = strtolower ($ site) " ; On Wikipedia URL, all of which include "wikipedia.org".

How can I write a function which will skip the "$ site = strtolower ($ site)" phase; "If $ The site contains "wikipedia.org"?

Thank you in advance,

John

* Nix All URLs on the server are case-sensitive.

Edit: The domain name is case-insensitive (in fact, the customer converts it to lowercase).

  http: // user: pass@domain.com/somedir/somefile.ext? SomeQueryString = someValue # fragment ======= ---------- ===== ===== ------------------ --------------------------- ----------- Legend: - Case sensitive =: Case insensitive  Specifications are case sensitive according to pieces, but it has not been implemented on all clients in this manner.  

This is a very bad idea to do the best way you are trying to do just to shorten the domain name.

Edit 2: Because you asked, this is an act that will properly shorten a given URL (only plan and domain): < Previous> function urltolower ($ url) {$ parts = @ parse_url ($ url); FALSE return ($ parts === FALSE); $ Url = ''; If (empty! ($ Parts ['scheme'])) $ url = Strtolower ($ parts ['scheme']) (($ parts ['scheme'] == 'file')? ': ///': ': //'); If (empty! ($ Parts ['user'])) $ url = $ Parts ['user'] ((empty ($ parts ['pass'])) ':'. $ Parts ['pass']: '') '@'; If (empty! ($ Parts ['host'])) $ url = Stormwar ($ Part ['Host']); If (empty! ($ Parts ['port']) $ url = ':'. $ Parts ['port']; If (empty! ($ Parts ['path'])) $ url = $ Parts ['path']; If (empty! ($ Parts ['query'])) $ url = '?' . $ Parts ['curiosity']; If (empty! ($ Parts ['piece'])) $ url = '#' $ Parts ['piece']; Return $ url; } [Mixed] urltolower ($ url)

Fails to minimize a URL On FALSE Returns the low-priority URL to return success.

Example:

  echo urltolower ('http://en.WikiPedia.org/wiki/PHP'); // resonance http://en.wikipedia.org/wiki/PHP  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -