Blur Blur - 1 year ago 103
PHP Question

How do I remove http, https and slash from user input in php

Example user input

I want a php function to make the output like

Let me know :)

Answer Source

You should use an array of "disallowed" terms and use strpos and str_replace to dynamically remove them from the passed-in URL:

function remove_http($url) {
   $disallowed = array('http://', 'https://');
   foreach($disallowed as $d) {
      if(strpos($url, $d) === 0) {
         return str_replace($d, '', $url);
   return $url;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download