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

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -