Jump to content

determining and removing an element of an array


BahBah

Recommended Posts

Hello

 

I have an array $data which contains post data sent to my user class. In this array will be an element called "group".

 

Everything apart from "group" (which signifies the group the user is to be assigned) is inputted into the database in a single SQL insert. So after escaping the $data is imploded for the table field names and values for the SQL query.

 

I would like to remove "group" and its corresponding value from the $data array and set the group value to a variable. I then intend to execute another query adding this user (last_insert_id) into a different table.

 

Is this possible ? I've been looking through the PHP documentation and haven't been able to find anything suitable.

 

I suppose one solution would be to use:

 

$group = $data['group'];
// then
unset($data['group'])

 

but it doesn't seem very elegant.

 

Thank you

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.