簡體   English   中英

如何刪除表格中的http:// www?

[英]How do i remove http://www in form?

我要刪除

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>

你們有小費嗎?

使用數組和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
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;
}

您可以使用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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM