In Python I would do something like this heaving the following dictionary (equiv of php's assoc array).
arr = {'id': '1', 'name': 'marcin', 'born': '1981-10-23'}
print ', '.join([('`%s` = "%s"') % (k,v) for k,v in arr.items()])
to get:
`born` = "1981-10-23", `id` = "1", `name` = "marcin"
Assuming PHP array is:
array("id"=>"1","name"=>"marcin","born"=>"1981-10-23");
Is there a way of getting the same result in PHP 5.3 without using foreach loop?
json_encode()is really handy for something structured, and very similar to what you are looking for. And then, you don't have to worry about escaping and what not, as it does it for you.