1

我想删除

https://www<br>
http://www <br>
https://<br>
http://<br>

像这样的形式:

<form class="well" action="process.php">
<input type="text" name="q" placeholder="{$lang.placeholder}" x-webkit-speech>
<select name="t">
    <option value="domain">{$lang.domain}</option>
    <option value="ip">{$lang.ip}</option>
    <option value="nameserver">{$lang.nameserver}</option>
</select>
<button type="submit" class="btn"><i class="icon"></i> {$lang.button}</button>

你们有小费吗!?

4

3 回答 3

4

使用数组和str_replace

$remove = array('https://', 'http://www', 'https://', 'http://');

$test='http://stackoverflow.com/questions/18464723/how-do-i-remove-http-www-in-form';

echo str_replace($remove, '', $test);

输出:

stackoverflow.com/questions/18464723/how-do-i-remove-http-www-in-form
于 2013-08-27T12:04:01.847 回答
1
function postwithoutspace($post)
{
    foreach($post as $key=>$value)
    {
        $value= htmlspecialchars(mysql_real_escape_string(trim($value)));
        $value = str_ireplace("https://www", "blocked", $value);
                $value = str_ireplace("http://www", "blocked", $value);
                $value = str_ireplace("https://", "blocked", $value);
                $value = str_ireplace("http://", "blocked", $value);
        $post[$key]= $value;
    }
    return  $post;
}
于 2013-08-27T12:06:03.930 回答
1

您可以使用str_replace。使用此功能:

function http_www_remover($myString) {
  $return = str_replace( "https://www", "" , $myString);
  $return = str_replace( "http://www", "" , $myString);
  $return = str_replace( "https://" , "" , $myString);
  $return = str_replace( "http://" , "" , $myString);
  echo $return;
}

<form class="well" action="process.php">
<input type="text" name="q" placeholder="<? http_www_remover({$lang.placeholder});?>" x-webkit-speech>
<select name="t">
    <option value="domain"><? http_www_remover({$lang.domain});?></option>
    <option value="ip"><? http_www_remover({$lang.ip});?></option>
    <option value="nameserver"><? http_www_remover({$lang.nameserver});?></option>
</select>
<button type="submit" class="btn"><i class="icon"></i> <? http_www_remover({$lang.button});?></button>
于 2013-08-27T12:10:10.427 回答