I run a situation where I put stuff into array like that:
$current_pms[] = array(
'from' => sofa_get_username($current_user->ID),
'to' => $valid_user,
'subject' => $subject,
'message' => $message,
'status' => 'unread',
'time' => current_time('mysql', $gmt = 0)
);
How can I mark each entry with its own unique ID so I can grab it later?
Thanks
You can always self-assign incremental numbers, that's one option.
$id = count($array)+1;
$array[$id] = array (...)
Or you can just use any key/value pairs.
$array['id'] = ...
$array[123] = ...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.