Jump to content

How to implode 3rd value in array


t_machine

Recommended Posts

Hi, I would appreciate if anyone could help with this.
I am using the following array of columns in my database query. I am using the sprintf function.

This is my array of columns
$mytbls= array('id', 'user_id', 'groupid', 'expire');

I would like to use only the groupid from that array in something like the following

$sql = sprintf("SELECT %s FROM TABLE_NAME",
                  implode(', ', $mytbls)
                  );
If I keep it as the above, it will select all my columns but I only need the "groupid".

Thanks :)
Link to comment
https://forums.phpfreaks.com/topic/28250-how-to-implode-3rd-value-in-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.