Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • Why count ($variables) - 1) . '?'; Why not just count($variable) Commented Jun 8, 2016 at 21:43
  • 2
    @RobertRocha Because you need one fewer commas than there are variables Commented Jun 9, 2016 at 13:45
  • 1
    I have tried to add another variable in execute statement using array but it isn't working. Commented Oct 5, 2020 at 14:13
  • How about implode(', ', array_fill(0, count($variables), '?')) Commented Nov 12, 2021 at 18:46
  • @AlexeyKosov That's also an option, yes. The key point is ensuring you've generated placeholders that match up to the number of values in the input. Commented Nov 19, 2021 at 14:14