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

haskell - Using filter on an item in a list? -

tomcat6 - Exception when stopping container for a with Spring + Quartz + Tomcat web application -

c# - Binding attached property to IEnumerable -