php - Convert array values to a comma-delimited string, with numbers replaced by '?' -


my array:

$numbers = array(1, 3, 5); 

simply, need change numbers ? question mark , separated , comma.

// output (array has 3 items):  $string = '?, ?, ?'; 

you can use combination of str_repeat , count. use rtrim clean trailing comma:

$numbers = array(1, 3, 5); $str = str_repeat('?, ', count($numbers)); $str = rtrim($str, ', '); echo $str;  // output: ?, ?, ?  

Comments

Popular posts from this blog

Cursor error with postgresql, pgpool and php -

delphi - ESC/P programming! -

c++ - error: use of deleted function -