I was wondering how I could go about accessing values within an object, such as 'backpackPosition'? I'm guessing I would have to put it in some kind of foreach loop, but I have no idea how to get the values.
TF2Inventory Object
(
[fetchDate] => 1234541231
[items] => Array
(
[60] => TF2Item Object
(
[equipped] => Array
(
[scout] => 1
[sniper] => 1
[soldier] => 1
[demoman] => 1
[medic] => 1
[heavy] => 1
[pyro] => 1
[spy] => 1
)
[attributes] => Array
(
[0] => stdClass Object
(
[name] => custom employee number
[class] => set_employee_number
[value] => 0
)
[1] => stdClass Object
(
[name] => cannot trade
[class] => cannot_trade
[value] => 1
)
)
[backpackPosition] => 61
[className] => tf_wearable
[count] => 1
[defindex] => 170
[id] => 535518002
[level] => 20
[name] => Primeval Warrior
[quality] => unique
[slot] => misc
[tradeable] =>
[type] => Badge
)
[43] => TF2Item Object
(
[equipped] => Array
(
[scout] => 0
[sniper] => 0
[soldier] => 0
[demoman] => 0
[medic] => 0
[heavy] => 0
[pyro] => 0
[spy] => 0
)
[attributes] => Array
(
[0] => stdClass Object
(
[name] => cannot trade
[class] => cannot_trade
[value] => 1
)
)
[backpackPosition] => 44
[className] => tf_wearable
[count] => 1
[defindex] => 471
[id] => 535518003
[level] => 50
[name] => Proof of Purchase
[quality] => unique
[slot] => head
[tradeable] =>
[type] => Hat
)
[42] => TF2Item Object
(
[equipped] => Array
(
[scout] => 1
[sniper] => 1
[soldier] => 1
[demoman] => 1
[medic] => 1
[heavy] => 1
[pyro] => 1
[spy] => 1
)
[attributes] =>
[backpackPosition] => 43
[className] => tf_wearable
[count] => 1
[defindex] => 278
[id] => 541628464
[level] => 31
[name] => Horseless Headless Horsemann's Head
[quality] => unique
[slot] => head
[tradeable] =>
[type] => Hat
)
[59] => TF2Item Object
(
[equipped] => Array
(
[scout] => 0
[sniper] => 0
[soldier] => 0
[demoman] => 0
[medic] => 0
[heavy] => 0
[pyro] => 0
[spy] => 0
)
[attributes] => Array
(
[0] => stdClass Object
(
[name] => cannot trade
[class] => cannot_trade
[value] => 1
)
)
[backpackPosition] => 60
[className] => tf_wearable
[count] => 1
[defindex] => 115
[id] => 548155039
[level] => 10
[name] => Mildly Disturbing Halloween Mask
[quality] => unique
[slot] => head
[tradeable] =>
[type] => Holiday Hat
)
foreach($inventory_object->items as $item)
{
$item->backpackPosition;
}
Related
So inside my main Joomla template/index.php file I am doing the following to try and get the category id number of the page the user is currently viewing.
The result should be 9 since that is the id number of the category
jimport('joomla.application.categories');
$category = JCategories::getInstance('hwdMediaShare')->get($this->item->categories[0]->id[0]);
print_r($category);
echo "\n\nCategory ID number is : ".($category)."\n\n";
My var_dump shows this (category id number 9 does exist and is present in the var dump so I should be able to obtain it)
[id] => 9
9:random
Shows category id 9 is there and its name too "random"
JCategoryNode Object ( [id] => root [asset_id] => 0 [parent_id] => 0 [lft] => 0 [rgt] => 21 [level] => 0 [extension] => system [title] => ROOT [alias] => root [description] => [published] => 1 [checked_out] => 0 [checked_out_time] => 0000-00-00 00:00:00 [access] => 1 [params] => {} [metadesc] => [metakey] => [metadata] => {} [created_user_id] => 42 [created_time] => 2011-01-01 00:00:01 [modified_user_id] => 0 [modified_time] => 0000-00-00 00:00:00 [hits] => 0 [language] => * [numitems] => [childrennumitems] => [slug] => 1:root [assets] => [_parent:protected] => [_children:protected] => Array ( [0] => JCategoryNode Object ( [id] => 9 [asset_id] => 610 [parent_id] => root [lft] => 3 [rgt] => 4 [level] => 1 [extension] => com_hwdmediashare [title] => Random [alias] => random [description] => [published] => 1 [checked_out] => 0 [checked_out_time] => 0000-00-00 00:00:00 [access] => 1 [params] => {"category_layout":"","image":""} [metadesc] => [metakey] => [metadata] => {"author":"","robots":""} [created_user_id] => 571 [created_time] => 2016-02-10 11:52:24 [modified_user_id] => 571 [modified_time] => 2016-03-16 15:45:36 [hits] => 1107 [language] => * [numitems] => [childrennumitems] => [slug] => 9:random [assets] => [_parent:protected] => JCategoryNode Object *RECURSION* [_children:protected] => Array ( ) [_path:protected] => Array ( [0] => 9:random ) [_leftSibling:protected] => [_rightSibling:protected] => [_allChildrenloaded:protected] => 1 [_constructor:protected] => hwdMediaShareCategories Object ( [_nodes:protected] => Array ( [root] => JCategoryNode Object *RECURSION* [9] => JCategoryNode Object *RECURSION* ) [_checkedCategories:protected] => Array ( [9] => 1 ) [_extension:protected] => com_hwdmediashare [_table:protected] => #__hwdms_category_map [_field:protected] => category_id [_key:protected] => id [_statefield:protected] => state [_options:protected] => Array ( [table] => #__hwdms_category_map [extension] => com_hwdmediashare [field] => category_id [published] => 0 [access] => true ) ) [_errors:protected] => Array ( ) [note] => [path] => uncategorised/test/uncategorised/random [version] => 1 ) ) [_path:protected] => Array ( ) [_leftSibling:protected] => [_rightSibling:protected] => [_allChildrenloaded:protected] => [_constructor:protected] => hwdMediaShareCategories Object ( [_nodes:protected] => Array ( [root] => JCategoryNode Object *RECURSION* [9] => JCategoryNode Object ( [id] => 9 [asset_id] => 610 [parent_id] => root [lft] => 3 [rgt] => 4 [level] => 1 [extension] => com_hwdmediashare [title] => Random [alias] => random [description] => [published] => 1 [checked_out] => 0 [checked_out_time] => 0000-00-00 00:00:00 [access] => 1 [params] => {"category_layout":"","image":""} [metadesc] => [metakey] => [metadata] => {"author":"","robots":""} [created_user_id] => 571 [created_time] => 2016-02-10 11:52:24 [modified_user_id] => 571 [modified_time] => 2016-03-16 15:45:36 [hits] => 1107 [language] => * [numitems] => [childrennumitems] => [slug] => 9:random [assets] => [_parent:protected] => JCategoryNode Object *RECURSION* [_children:protected] => Array ( ) [_path:protected] => Array ( [0] => 9:random ) [_leftSibling:protected] => [_rightSibling:protected] => [_allChildrenloaded:protected] => 1 [_constructor:protected] => hwdMediaShareCategories Object *RECURSION* [_errors:protected] => Array ( ) [note] => [path] => uncategorised/test/uncategorised/random [version] => 1 ) ) [_checkedCategories:protected] => Array ( [9] => 1 ) [_extension:protected] => com_hwdmediashare [_table:protected] => #__hwdms_category_map [_field:protected] => category_id [_key:protected] => id [_statefield:protected] => state [_options:protected] => Array ( [table] => #__hwdms_category_map [extension] => com_hwdmediashare [field] => category_id [published] => 0 [access] => true ) ) [_errors:protected] => Array ( ) [note] => [path] => [version] => 1 ) Category ID number is : JCategoryNode
And when I try to echo my output to see my number I see this
Category ID number is : JCategoryNode
Can anyone see what I am doing wrong here and correct me.
It should say
Category ID number is : 9
I am working on a project where I am creating a plugin that works on top of ACF 5. I have made it pretty far but right now I am stuck on this issue:
I have a flexible content field setup that has multiple sub layouts. I need to add conditional logic to each of these layouts based on there names. Right now I am doing it by getting their field ID:
$field_id = $field['ID'];
$field being my main array.
Then doing a simple php switch statement just setting a variable I can then check for when doing conditional logic:
$layout = '';
switch ($field_id) {
case "19":
$layout = "html";
break;
case "28":
$layout = "grid";
break;
}
Then I just check to see what $layout is set to and go from there. While this does work I do not like the fact that I have to update the IDs every time I move development environments or re-create a layout.
Does anyone know how a better way to do this?
Array dump for single $field:
Array
(
[padding_top] => 0
[padding_right] => 0
[padding_bottom] => 0
[padding_left] => 0
[background_style] => default
[section_width] => default
[ID] => 28
[key] => field_5876368ea05b4
[label] => Section Styles
[name] => acf[field_5873e9fdacab1][0][field_5876368ea05b4]
[prefix] => acf[field_5873e9fdacab1][0]
[type] => section_styles
[value] => Array
(
[section_width] => default
[margin_top] =>
[margin_right] =>
[margin_bottom] =>
[margin_left] =>
[padding_top] =>
[padding_right] =>
[padding_bottom] =>
[padding_left] =>
[background_color] =>
[background_image] =>
[background_style] => default
[background_position_1] => top
[background_position_2] => left
)
[menu_order] => 0
[instructions] =>
[required] => 0
[id] => acf-field_5873e9fdacab1-0-field_5876368ea05b4
[class] =>
[conditional_logic] => 0
[parent] => 14
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[_name] => section_styles
[_prepare] => 1
[_valid] => 1
[parent_layout] => 58763683a05b3
[margin_top] =>
[margin_right] =>
[margin_bottom] =>
[margin_left] =>
[background_color] =>
[background_position_1] => top
[background_position_2] => left
)
Array dump for main builder object:
Array
(
[layouts] => Array
(
[0] => Array
(
[key] => 5873ea05b5bf2
[name] => html_section
[label] => HTML Section
[display] => block
[sub_fields] => Array
(
[0] => Array
(
[placement] => top
[endpoint] => 0
[ID] => 15
[key] => field_5873f2366de0c
[label] => Content
[name] =>
[prefix] => acf
[type] => tab
[value] =>
[menu_order] => 0
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 14
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[_name] =>
[_prepare] => 0
[_valid] => 1
[parent_layout] => 5873ea05b5bf2
)
[1] => Array
(
[tabs] => all
[toolbar] => full
[media_upload] => 1
[default_value] =>
[delay] => 0
[ID] => 16
[key] => field_5873f2456de0d
[label] => Content
[name] => content
[prefix] => acf
[type] => wysiwyg
[value] =>
[menu_order] => 1
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 14
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[_name] => content
[_prepare] => 0
[_valid] => 1
[parent_layout] => 5873ea05b5bf2
)
[2] => Array
(
[multiple] => 0
[allow_null] => 1
[choices] => Array
(
[narrow-width] => Narrow
[default-width] => Default
[full-width] => Full Width
)
[default_value] => Array
(
[0] => default-width
)
[ui] => 0
[ajax] => 0
[placeholder] =>
[return_format] => value
[ID] => 17
[key] => field_5873f2616de0e
[label] => Width
[name] => width
[prefix] => acf
[type] => select
[value] =>
[menu_order] => 2
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 14
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[_name] => width
[_prepare] => 0
[_valid] => 1
[parent_layout] => 5873ea05b5bf2
)
[3] => Array
(
[placement] => top
[endpoint] => 0
[ID] => 18
[key] => field_5873f28e6de0f
[label] => Apperance
[name] =>
[prefix] => acf
[type] => tab
[value] =>
[menu_order] => 3
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 14
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[_name] =>
[_prepare] => 0
[_valid] => 1
[parent_layout] => 5873ea05b5bf2
)
[4] => Array
(
[padding_top] => 0
[padding_right] => 0
[padding_bottom] => 0
[padding_left] => 0
[background_style] => default
[section_width] => default
[ID] => 19
[key] => field_5873f2976de10
[label] => Section Styles
[name] => section_styles
[prefix] => acf
[type] => section_styles
[value] =>
[menu_order] => 4
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 14
[wrapper] => Array
(
[width] => 100
[class] =>
[id] =>
)
[_name] => section_styles
[_prepare] => 0
[_valid] => 1
[margin_top] => 0
[margin_right] => 0
[margin_bottom] => 0
[margin_left] => 0
[border_top] => 0
[border_right] => 0
[border_bottom] => 0
[border_left] => 0
[border_style] => solid
[border_color] =>
[background_color] =>
[background_position_1] => top
[background_position_2] => left
[parent_layout] => 5873ea05b5bf2
)
)
[min] =>
[max] =>
)
[1] => Array
(
[key] => 58763683a05b3
[name] => grid_section
[label] => Grid Section
[display] => block
[sub_fields] => Array
(
[0] => Array
(
[padding_top] => 0
[padding_right] => 0
[padding_bottom] => 0
[padding_left] => 0
[background_style] => default
[section_width] => default
[ID] => 28
[key] => field_5876368ea05b4
[label] => Section Styles
[name] => section_styles
[prefix] => acf
[type] => section_styles
[value] =>
[menu_order] => 0
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 14
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[_name] => section_styles
[_prepare] => 0
[_valid] => 1
[parent_layout] => 58763683a05b3
[margin_top] =>
[margin_right] =>
[margin_bottom] =>
[margin_left] =>
[background_color] =>
[background_position_1] => top
[background_position_2] => left
)
)
[min] =>
[max] =>
)
)
[min] =>
[max] =>
[button_label] => Add Row
[ID] => 14
[key] => field_5873e9fdacab1
[label] => Main Builder
[name] => main_builder
[prefix] => acf
[type] => flexible_content
[value] => Array
(
[0] => Array
(
[acf_fc_layout] => grid_section
[section_styles] => Array
(
[section_width] => default
[margin_top] =>
[margin_right] =>
[margin_bottom] =>
[margin_left] =>
[padding_top] =>
[padding_right] =>
[padding_bottom] =>
[padding_left] =>
[background_color] =>
[background_image] =>
[background_style] => default
[background_position_1] => top
[background_position_2] => left
[background_position] => top left
[padding] => 0 0 0 0
)
)
[1] => Array
(
[acf_fc_layout] => html_section
[content] =>
[width] => default-width
[section_styles] => Array
(
[section_width] => default
[margin_top] => uk-margin-large-top
[margin_right] => uk-margin-small-right
[margin_bottom] => uk-margin-medium-bottom
[margin_left] =>
[padding_top] =>
[padding_right] =>
[padding_bottom] =>
[padding_left] =>
[background_color] =>
[background_image] =>
[background_style] => default
[background_position_1] => top
[background_position_2] => left
[background_position] => top left
[padding] => 0 0 0 0
)
)
)
[menu_order] => 0
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 13
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[_name] => main_builder
[_prepare] => 0
[_valid] => 1
)
Hi my zend paginator works well when the $business_list array format is like below.
but when the array format changes it displays only one page instead of many pages.
$paginator = Zend_Paginator::factory($business_list);
Array
(
[0] => Array
(
[id] => 216
[userid] => 141
[title] => first req
[image] =>
[logo] =>
[description] =>
this is the first requirment
[date] => 2012-06-12 10:31:01
[area] => 1
[budget] => 1
[type] => 1
[status] => 1
[CmBusinessSection] => Array
(
[0] => Array
(
[id] => 315
[business_id] => 216
[section_id] => 1
[subsection_id] => 13
[description] =>
)
[1] => Array
(
[id] => 316
[business_id] => 216
[section_id] => 3
[subsection_id] => 14
[description] =>
)
[2] => Array
(
[id] => 317
[business_id] => 216
[section_id] => 4
[subsection_id] => 15
[description] =>
)
)
[CmUser] => Array
(
[id] => 141
[username] => venki
[password] =>
[firstname] => venkatesh
[lastname] => abus
[image] => 54winter.jpg
[email] => xxx#xx.com
[phone] => 23423452
[group_id] => 2
[status] =>
[registered_date] => 2012-06-04 06:32:58
[last_visit] => 0000-00-00 00:00:00
[is_active] => 1
[subscribe] => 1
)
)
[1] => Array
(
[id] => 214
[userid] => 98
[title] => gopicontractor
[image] => 54bluehills.jpg
[logo] => 239waterlilies.jpg
[description] =>
TIt uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is
[date] => 2012-06-11 12:18:58
[area] => 1
[budget] => 1
[type] => 3
[status] => 1
[CmBusinessSection] => Array
(
[0] => Array
(
[id] => 305
[business_id] => 214
[section_id] => 1
[subsection_id] => 5
[description] =>
)
[1] => Array
(
[id] => 306
[business_id] => 214
[section_id] => 1
[subsection_id] => 6
[description] =>
)
[2] => Array
(
[id] => 307
[business_id] => 214
[section_id] => 3
[subsection_id] => 1
[description] =>
)
[3] => Array
(
[id] => 308
[business_id] => 214
[section_id] => 4
[subsection_id] => 9
[description] =>
)
)
[CmUser] => Array
(
[id] => 98
[username] => gopi.s
[password] =>
[firstname] => venkatesh
[lastname] => franc
[image] =>
[email] => ss#ss.com
[phone] => 23423452
[group_id] => 3
[status] =>
[registered_date] => 2012-05-16 12:36:57
[last_visit] => 0000-00-00 00:00:00
[is_active] => 1
[subscribe] => 1
)
)
)
the above array format displays paginatin correctly.
This is the array that displays only one page in pagination.
Zend_Paginator Object
(
[_cacheEnabled:protected] => 1
[_adapter:protected] => Zend_Paginator_Adapter_Array Object
(
[_array:protected] => Array
(
[0] => Array
(
[id] => 89
[username] => xx
[password] => xx
[firstname] => xx
[lastname] => xx
[image] =>
[email] => xx#ymail.com
[phone] => 2342345
[group_id] => 2
[status] => offline
[registered_date] => 2012-05-15 10:58:53
[last_visit] =>
[is_active] => 1
[subscribe] => 0
[CmBusiness] => Array
(
[0] => Array
(
[id] => 204
[userid] => 89
[title] => xxhousing
[image] => 760067.jpg
[logo] => xx_818f3c97e6_o.jpg
[description] => xx
[date] => 2012-05-31 13:36:17
[area] => 1
[budget] => 1
[type] => 1
[status] => 1
[CmAmount] => Array
(
[id] => 1
[amount] => 1000-1500
[status] => 1
)
[CmBusinessSection] => Array
(
[0] => Array
(
[id] => 251
[business_id] => 204
[section_id] => 1
[subsection_id] => 6
[description] => xx
)
[1] => Array
(
[id] => 252
[business_id] => 204
[section_id] => 3
[subsection_id] => 2
[description] => xx
)
[2] => Array
(
[id] => 253
[business_id] => 204
[section_id] => 3
[subsection_id] => 4
[description] => xx
)
[3] => Array
(
[id] => 254
[business_id] => 204
[section_id] => 4
[subsection_id] => 9
[description] => xx
)
)
[CmArea] => Array
(
[id] => 1
[area] => manchester
[status] => 1
)
[CmType] => Array
(
[id] => 1
[type] => Personal business
[status] => 1
)
)
[1] => Array
(
[id] => 205
[userid] => 89
[title] => xx
[image] => 41217850-desktop-wallpapers-new-windows-xp.jpg
[logo] => 356anger_n.jpg
[description] => xx
[date] => 2012-05-31 13:37:15
[area] => 1
[budget] => 1
[type] => 3
[status] => 1
[CmAmount] => Array
(
[id] => 1
[amount] => 1000-1500
[status] => 1
)
[CmBusinessSection] => Array
(
[0] => Array
(
[id] => 255
[business_id] => 205
[section_id] => 1
[subsection_id] => 6
[description] =>xx
)
[1] => Array
(
[id] => 256
[business_id] => 205
[section_id] => 3
[subsection_id] => 1
[description] => xx
)
[2] => Array
(
[id] => 257
[business_id] => 205
[section_id] => 3
[subsection_id] => 2
[description] => xx
)
[3] => Array
(
[id] => 258
[business_id] => 205
[section_id] => 4
[subsection_id] => 10
[description] => xx
)
)
[CmArea] => Array
(
[id] => 1
[area] => manchester
[status] => 1
)
[CmType] => Array
(
[id] => 3
[type] => Bilde companies
[status] => 1
)
)
[2] => Array
(
[id] => 206
[userid] => 89
[title] => Nuestros recursos
[image] =>
[logo] =>
[description] => xx
[date] => 2012-05-31 13:38:04
[area] => 1
[budget] => 1
[type] => 4
[status] => 1
[CmAmount] => Array
(
[id] => 1
[amount] => 1000-1500
[status] => 1
)
[CmBusinessSection] => Array
(
[0] => Array
(
[id] => 259
[business_id] => 206
[section_id] => 1
[subsection_id] => 5
[description] =>
)
[1] => Array
(
[id] => 260
[business_id] => 206
[section_id] => 1
[subsection_id] => 6
[description] =>
)
[2] => Array
(
[id] => 261
[business_id] => 206
[section_id] => 3
[subsection_id] => 2
[description] =>
)
[3] => Array
(
[id] => 262
[business_id] => 206
[section_id] => 4
[subsection_id] => 10
[description] =>
)
)
[CmArea] => Array
(
[id] => 1
[area] => manchester
[status] => 1
)
[CmType] => Array
(
[id] => 4
[type] => Designer
[status] => 1
)
)
)
)
)
[_count:protected] => 1
)
[_currentItemCount:protected] =>
[_currentItems:protected] =>
[_currentPageNumber:protected] => 1
[_filter:protected] =>
[_itemCountPerPage:protected] => 2
[_pageCount:protected] => 1
[_pageRange:protected] =>
[_pages:protected] =>
[_view:protected] =>
)
I've got an array of objects as follows ; how can I filter out (remove) the objects that have admins->member = 11 ?
In this example, the resulting array object would only have the 1st object that [245] at the start.
Array
(
[245] => stdClass Object
(
[name] => Programmation Web
[description] =>
[public] => 0
[jointype] => controlled
[grouptype] => course
[membershiptype] => member
[reason] =>
[role] => tutor
[ctime] => 2011-10-12 14:41:35
[mtime] => 0000-00-00 00:00:00
[image] =>
[session_id] => 28
[session_name] => Hiver 2012
[membercount] => 1
[favorite] =>
[requests] => 0
[id] => 245
[members] => Array
(
[0] => stdClass Object
(
[id] => 11
[name] => Yves Otis (otisyves)
)
)
[projects] => Array
(
[0] => stdClass Object
(
[id] => 1923
[title] => Sans titre (1)
[description] =>
[owner] => 11
[ownerformat] =>
[group] =>
[institution] =>
[startdate] =>
[stopdate] =>
[ctime] => 2011-10-12 13:24:26
[mtime] => 2011-10-12 13:24:26
[atime] => 2011-10-12 13:24:26
[submittedgroup] => 245
[submittedhost] =>
[submittedtime] => 2011-10-12 17:00:41
[numcolumns] => 3
[layout] =>
[theme] =>
[template] => 0
[copynewuser] => 0
[type] => portfolio
[visits] => 0
[allowcomments] => 1
[approvecomments] => 0
[skills] =>
[instructions] =>
[accessconf] =>
[image] =>
[competencesvisees] =>
[consignes] =>
[fichierconsignes] =>
[groupevise] =>
)
)
[project_count] => 1
[admins] => Array
(
[0] => stdClass Object
(
[member] => 11
[firstname] => Yves
[lastname] => Otis
)
)
[topic_name] => Le PHP
[activites] => Array
(
[0] => stdClass Object
(
[topic_name] =>
[topic_id] => 42
[post_parent] => 107
[post_body] => Oui moi aussi je me demande ça.
[post_id] => 109
)
)
[forums] => Array
(
[0] => stdClass Object
(
[forum_name] => Discussion générale
[forum_id] => 101
)
)
)
[246] => stdClass Object
(
[name] => Les bases de données
[description] =>
[public] => 0
[jointype] => controlled
[grouptype] => course
[membershiptype] => admin
[reason] =>
[role] => admin
[ctime] => 2011-10-13 15:27:30
[mtime] => 0000-00-00 00:00:00
[image] =>
[session_id] => 27
[session_name] => Automne 2011
[membercount] => 0
[favorite] =>
[requests] => 0
[id] => 246
[project_count] => 0
[topic_name] => Difficulté
[activites] => Array
(
[0] => stdClass Object
(
[topic_name] =>
[topic_id] => 44
[post_parent] => 111
[post_body] => Ouah!
[post_id] => 112
)
)
[forums] => Array
(
[0] => stdClass Object
(
[forum_name] => Le MySQL
[forum_id] => 103
)
)
)
)
I'd like to check against the index
$arr = array_filter($arr, function($item) {
if (!isset($item->admins) || !is_array($item->admins)) {
return false;
}
foreach ($item->admins as $admin) {
if ($admin->member == 11) {
return true;
}
}
return false;
});
[5] => Array
(
[id] => 29372
[product_id] => Array
(
[0] => stdClass Object
(
[id] => 1469
[type_id] => 1
[title] => Hearth 2 Hearth
[cover] => 21cf9d7d09d403251ba5d01ff33cd089.jpg
[coverid] => 1178
[inserted_by] => 0
[inserted_date] => 2011-02-11 13:55:23
[status_id] => 0
)
)
[variable_id] => 9
[variable_value] => 2011-02-11
[master_value] =>
[released_date] => 2011-02-11
[price] => Array
(
[0] => Array
(
[product_id] => 1469
[media_format] => VCD
[price] => 29000
[discount] => 5
)
)
[media_format] => VCD
)
[6] => Array
(
[id] => 30074
[product_id] => Array
(
[0] => stdClass Object
(
[id] => 1470
[type_id] => 1
[title] => Hearth 2 Hearth
[cover] => 149ddd4d1d5e567c1300d4831323e1c5.jpg
[coverid] => 1177
[inserted_by] => 6
[inserted_date] => 2011-02-16 15:18:58
[status_id] => 0
)
)
[variable_id] => 9
[variable_value] => 2011-02-11
[master_value] =>
[released_date] => 2011-02-11
[price] => Array
(
[0] => Array
(
[product_id] => 1470
[media_format] => DVD
[price] => 39000
[discount] => 0
)
)
[media_format] => DVD
)
I want the result by media_format = DVD so the whole array is gone, is there anyway to delete an array or remove it?
The same way you "delete" any variable:
unset($array[$index]);