Posted by mikedrupalfan on November 24, 2012 at 2:26am
Hi,
I'm a new developer and i have a two question.
1)
that is the code:
Why there is the bold sections?
$instances = field_info_instances('node', 'job_post');
foreach ($instances as $instance_name => $instance) {
field_delete_instance($instance);
}
And not just:
$instances = field_info_instances('node', 'job_post');
foreach ($instances as $instance) {
field_delete_instance($instance);
}
?
2) Why there is an array_keys
foreach(array_keys(_job_post_installed_fields()) as $fields) {
field_delete_field($field);
}
Comments
Both work, the first gives
Both work, the first gives access to both the array index and element. The second loop only gives access to the element.
thanks, but, Why there is an
thanks,
but,
Why there is an array_keys
foreach(array_keys(_job_post_installed_fields()) as $fields) {
field_delete_field($field);
}
I am guessing
I am guessing _job_post_installed_fields() returns an array index by field name, in which case array_keys() would return an array of field names and field_delete_field() expects a field name.