[英]how can i replace every single character with a “?” mark in a string with php
所以例如我給了這個字符串
sbbibs
與 php 我想將其更改為
??????
我目前的查詢是這樣的,我還不能繼續嗎? 分數
namespace modules\xenforums\sql;
trait create_row {
function create_row($types, $table, $column, $param, $conn) {
$param = "'" . implode ( "', '", $param ) . "'";
$placeholders = str_split($types);
$a = str_replace(); // this is where i want to make every type to ?
// posible value of $type, sssissb
$query = "INSERT INTO {$table} ({$column}) VALUES ({$placeholders})";
var_dump($a);
}
}
我怎么能這樣做?
我這樣做是因為我做了一個 php mysqli 查詢生成器,現在我試圖用? 獲取給定參數的數量
iv 嘗試使用 str_replaces 但這僅適用於 1 個特定的
我也有為每個字符做 str_replace 的想法,但這太乏味了
iv 還考慮過只針對當前數據類型執行此操作,但對於其他數據庫系統,情況並非完全相同
當您想通過用問號替換每個字符來使字符串不可讀時,您可以:
結果將是這樣的:
$input = "Test";
$output = "";
for ($i =0 ; $i < strlen(input) ; $i++) {
$output .= "?";
}
一行代碼:
str_pad('', strlen($string), '?');
或者更好:
str_repeat('?', strlen($string));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.