Cannot serialize and unserialize an object to delete an object element PHP - php

Getting an instance like this:
$coreBootstrap = new PEP_Application_BootstrapCore(array('bootstrap' => $this));
Receives this object:
PEP_Application_BootstrapCore Object ( [_bootstrap:protected] => Bootstrap Object ( [_appNamespace:protected] => [_resourceLoader:protected] => [_application:protected] => PEP_Application Object ( [_autoloader:protected] => PEP_Autoloader Object ( [_autoloaders:protected] => Array ( [0] => Zend_Application_Module_Autoloader Object ( [_basePath:protected] => C:\LodgingPhp\com-ui-php\target\packaged-application\application [_components:protected] => Array ( [Default_Controller_Action_Helper] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/controllers/actions/helpers [Default_Module] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/modules [Default_Model_DbTable] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models/DbTable [Default_Model_Mapper] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models/mappers [Default_Form] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/forms [Default_Model] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models [Default_Plugin] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/plugins [Default_Service] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/services [Default_View_Helper] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/views/helpers [Default_View_Filter] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/views/filters ) [_defaultResourceType:protected] => model [_namespace:protected] => Default [_resourceTypes:protected] => Array ( [actionhelper] => Array ( [namespace] => Default_Controller_Action_Helper [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/controllers/actions/helpers ) [module] => Array ( [namespace] => Default_Module [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/modules ) [dbtable] => Array ( [namespace] => Default_Model_DbTable [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models/DbTable ) [mappers] => Array ( [namespace] => Default_Model_Mapper [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models/mappers ) [form] => Array ( [namespace] => Default_Form [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/forms ) [model] => Array ( [namespace] => Default_Model [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models ) [plugin] => Array ( [namespace] => Default_Plugin [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/plugins ) [service] => Array ( [namespace] => Default_Service [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/services ) [viewhelper] => Array ( [namespace] => Default_View_Helper [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/views/helpers ) [viewfilter] => Array ( [namespace] => Default_View_Filter [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/views/filters ) ) ) ) [_defaultAutoloader:protected] => Array ( [0] => PEP_Loader [1] => loadClass ) [_fallbackAutoloader:protected] => [_internalAutoloader:protected] => Array ( [0] => PEP_Autoloader Object *RECURSION* [1] => _autoload ) [_namespaces:protected] => Array ( [Zend_] => 1 [ZendX_] => 1 [WDPRO_] => 1 [PEP_] => 1 [controllers_helpers_] => 1 [Guzzle] => 1 [Symfony] => 1 ) [_namespaceAutoloaders:protected] => Array ( [Default_] => Array ( [0] => Zend_Application_Module_Autoloader Object ( [_basePath:protected] => C:\LodgingPhp\com-ui-php\target\packaged-application\application [_components:protected] => Array ( [Default_Controller_Action_Helper] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/controllers/actions/helpers [Default_Module] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/modules [Default_Model_DbTable] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models/DbTable [Default_Model_Mapper] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models/mappers [Default_Form] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/forms [Default_Model] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models [Default_Plugin] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/plugins [Default_Service] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/services [Default_View_Helper] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/views/helpers [Default_View_Filter] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/views/filters ) [_defaultResourceType:protected] => model [_namespace:protected] => Default [_resourceTypes:protected] => Array ( [actionhelper] => Array ( [namespace] => Default_Controller_Action_Helper [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/controllers/actions/helpers ) [module] => Array ( [namespace] => Default_Module [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/modules ) [dbtable] => Array ( [namespace] => Default_Model_DbTable [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models/DbTable ) [mappers] => Array ( [namespace] => Default_Model_Mapper [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models/mappers ) [form] => Array ( [namespace] => Default_Form [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/forms ) [model] => Array ( [namespace] => Default_Model [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models ) [plugin] => Array ( [namespace] => Default_Plugin [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/plugins ) [service] => Array ( [namespace] => Default_Service [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/services ) [viewhelper] => Array ( [namespace] => Default_View_Helper [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/views/helpers ) [viewfilter] => Array ( [namespace] => Default_View_Filter [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/views/filters ) ) ) ) ) [_suppressNotFoundWarnings:protected] => [_zfPath:protected] => ) [_bootstrap:protected] => Bootstrap Object *RECURSION* [_environment:protected] => local [_optionKeys:protected] => Array ( [0] => phpsettings [1] => includepaths [2] => bootstrap [3] => resources [4] => deviceprofiling [5] => pluginpaths [6] => autoloadernamespaces ) [_options:protected] => Array ( [phpSettings] => Array ( [log_errors] => 1 [date] => Array ( [timezone] => America/New_York ) [display_startup_errors] => 0 [display_errors] => 1 [error_reporting] => 32767 [error_log] => C:\LodgingPhp\com-ui-php\target/logs/php_error.log ) [includePaths] => Array ( [library] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/../library ) [bootstrap] => Array ( [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/Bootstrap.php [class] => Bootstrap ) [resources] => Array ( [frontController] => Array ( [controllerDirectory] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/controllers [moduleDirectory] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/modules ) [layout] => Array ( [layoutPath] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/layouts/scripts ) [setsystemtime] => Array ( [load] => ) [session] => Array ( [strict] => ) [modules] => Array ( [0] => api [1] => tickets [2] => events [3] => passes [4] => plan [5] => resortaddons [6] => debugutils [7] => visa-instant-credit ) [view] => [log] => Array ( [logConfig] => /configs/log.ini ) [stats] => Array ( [serviceLogLevel] => INFO [requestResponseLogLevel] => DEBUG [viewLogLevel] => INFO [actionLogLevel] => INFO [appLogLevel] => INFO [memoryLogLevel] => DEBUG ) [serviceSuccessLog] => Array ( [logConfig] => /configs/serviceSuccessLog.ini ) ) [deviceprofiling] => Array ( [cookieName] => WDPROView [timeToLive] => 604800 [cookiePath] => / [enabled] => 1 [routeBlackList] => Array ( [0] => /api [1] => /utils ) ) [pluginpaths] => Array ( [PEP_Stats_Resource_] => PEP/Stats/Resource [PEP_Application_Resource_] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/../library/PEP/Application/Resource [Default_Resource_] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/resource ) [autoloadernamespaces] => Array ( [0] => WDPRO_ [1] => Zend_ [2] => PEP_ [3] => controllers_helpers_ [4] => Guzzle [5] => Symfony ) ) ) [_classResources:protected] => Array ( [autoload] => _initAutoload [core] => _initCore [router] => _initRouter [servicestub] => _initServiceStub [mediaengineconfig] => _initMediaEngineConfig [viewhelpers] => _initViewHelpers [configurablestoreplugin] => _initConfigurableStorePlugin [languagesetupplugin] => _initLanguageSetupPlugin [keywordrouterplugin] => _initKeywordRouterPlugin [tripconfig] => _initTripConfig [dclkeepalive] => _initDclKeepAlive [helpconfig] => _initHelpConfig [analyticsgenericplugin] => _initAnalyticsGenericPlugin [postdispatchstatsdplugin] => _initPostDispatchStatsDPlugin [curoauthplugin] => _initCUROAuthPlugin [sessionserviceshdrplugin] => _initSessionServiceShdrPlugin ) [_container:protected] => Zend_Registry Object ( [storage:ArrayObject:private] => Array ( [autoload] => Zend_Application_Module_Autoloader Object ( [_basePath:protected] => C:\LodgingPhp\com-ui-php\target\packaged-application\application [_components:protected] => Array ( [Default_Controller_Action_Helper] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/controllers/actions/helpers [Default_Module] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/modules [Default_Model_DbTable] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models/DbTable [Default_Model_Mapper] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models/mappers [Default_Form] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/forms [Default_Model] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models [Default_Plugin] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/plugins [Default_Service] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/services [Default_View_Helper] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/views/helpers [Default_View_Filter] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/views/filters ) [_defaultResourceType:protected] => model [_namespace:protected] => Default [_resourceTypes:protected] => Array ( [actionhelper] => Array ( [namespace] => Default_Controller_Action_Helper [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/controllers/actions/helpers ) [module] => Array ( [namespace] => Default_Module [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/modules ) [dbtable] => Array ( [namespace] => Default_Model_DbTable [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models/DbTable ) [mappers] => Array ( [namespace] => Default_Model_Mapper [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models/mappers ) [form] => Array ( [namespace] => Default_Form [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/forms ) [model] => Array ( [namespace] => Default_Model [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models ) [plugin] => Array ( [namespace] => Default_Plugin [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/plugins ) [service] => Array ( [namespace] => Default_Service [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/services ) [viewhelper] => Array ( [namespace] => Default_View_Helper [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/views/helpers ) [viewfilter] => Array ( [namespace] => Default_View_Filter [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/views/filters ) ) ) ) ) [_environment:protected] => [_optionKeys:protected] => Array ( [0] => phpsettings [1] => includepaths [2] => bootstrap [3] => resources [4] => deviceprofiling [5] => pluginpaths [6] => autoloadernamespaces ) [_options:protected] => Array ( [phpSettings] => Array ( [log_errors] => 1 [date] => Array ( [timezone] => America/New_York ) [display_startup_errors] => 0 [display_errors] => 1 [error_reporting] => 32767 [error_log] => C:\LodgingPhp\com-ui-php\target/logs/php_error.log ) [includePaths] => Array ( [library] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/../library ) [bootstrap] => Array ( [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/Bootstrap.php [class] => Bootstrap ) [resources] => Array ( [frontController] => Array ( [controllerDirectory] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/controllers [moduleDirectory] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/modules ) [layout] => Array ( [layoutPath] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/layouts/scripts ) [setsystemtime] => Array ( [load] => ) [session] => Array ( [strict] => ) [modules] => Array ( [0] => api [1] => tickets [2] => events [3] => passes [4] => plan [5] => resortaddons [6] => debugutils [7] => visa-instant-credit ) [view] => [log] => Array ( [logConfig] => /configs/log.ini ) [stats] => Array ( [serviceLogLevel] => INFO [requestResponseLogLevel] => DEBUG [viewLogLevel] => INFO [actionLogLevel] => INFO [appLogLevel] => INFO [memoryLogLevel] => DEBUG ) [serviceSuccessLog] => Array ( [logConfig] => /configs/serviceSuccessLog.ini ) ) [deviceprofiling] => Array ( [cookieName] => WDPROView [timeToLive] => 604800 [cookiePath] => / [enabled] => 1 [routeBlackList] => Array ( [0] => /api [1] => /utils ) ) [pluginpaths] => Array ( [PEP_Stats_Resource_] => PEP/Stats/Resource [PEP_Application_Resource_] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/../library/PEP/Application/Resource [Default_Resource_] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/resource ) [autoloadernamespaces] => Array ( [0] => WDPRO_ [1] => Zend_ [2] => PEP_ [3] => controllers_helpers_ [4] => Guzzle [5] => Symfony ) ) [_pluginLoader:protected] => [_pluginResources:protected] => Array ( [layout] => Array ( [layoutPath] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/layouts/scripts ) [setsystemtime] => Array ( [load] => ) [session] => Array ( [strict] => ) [modules] => Array ( [0] => api [1] => tickets [2] => events [3] => passes [4] => plan [5] => resortaddons [6] => debugutils [7] => visa-instant-credit ) [view] => [log] => Array ( [logConfig] => /configs/log.ini ) [stats] => Array ( [serviceLogLevel] => INFO [requestResponseLogLevel] => DEBUG [viewLogLevel] => INFO [actionLogLevel] => INFO [appLogLevel] => INFO [memoryLogLevel] => DEBUG ) [serviceSuccessLog] => Array ( [logConfig] => /configs/serviceSuccessLog.ini ) [frontcontroller] => Zend_Application_Resource_Frontcontroller Object ( [_front:protected] => [_bootstrap:protected] => Bootstrap Object *RECURSION* [_options:protected] => Array ( [controllerDirectory] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/controllers [moduleDirectory] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/modules ) [_skipOptions:protected] => Array ( [0] => options [1] => config ) ) ) [_run:protected] => Array ( [0] => autoload ) [_started:protected] => Array ( [core] => 1 ) ) [_options:protected] => Array ( ) [_skipOptions:protected] => Array ( [0] => options [1] => config ) )
I need to remove the setsystemtime part:
[setsystemtime] => Array ( [load] => )
but I cannot reach it, I have tried casting the array and later making an array_search but I get: "It brings Array to string conversion":
$coreBootstrap = array_merge(array_diff((array) $coreBootstrap, array('setsystemtime')));
Also I tried the following:
$a = serialize($coreBootstrap);
$x =json_encode($a);
$x= str_replace('s:13:\"setsystemtime\";a:1:{s:4:\"load\";s:1:\"1\";}', "", $x);
$a = json_decode($x, true);
$a = unserialize($a); // this brings an error and page doesnt load
// $logger->info($a);
$a = (object) $a;
$logger->info($x);
// $a->init();
$coreBootstrap->init();
Also
It's php 5.4.4
Any ideas?
Thank You!

Instead of trying to cast the array, why not cast $coreBootstrap to an array and unset the index, and then serialize or cast it back to an object?
// this should be done for each subindex that is also an object.
$a = (array) $coreBootstrap;
unset($a[..the index..]);
$a = (object) $a;
One can also try to go for a complete recursive conversion, but this might not be wanted:
$a = json_decode(json_encode($coreBootstrap, JSON_FORCE_OBJECT), false);
Its just better to do this specifically when dealing with a large array containing array's and objects.
$a = (array) $coreBootstrap->objectvar->objectvar;
unset($a[idofindex]);
$a = (object) $coreBootstrap->objectvar->objectvar;
$coreBootstrap->objectvar->objectvar = $a;

Related

Laravel - How can I add new array key with value to the collection output

I have this query:
$get_products = Cache::rememberForever('all_imports', function () use ($collection) {
return DB::connection('mongodb')->collection( $collection )->paginate( self::NO_OF_PRODUCTS );
});
If I print_r this output:
echo '<pre>';
print_r( $get_products );
echo '</pre>';
I got this request:
Illuminate\Pagination\LengthAwarePaginator Object
(
[items:protected] => Illuminate\Support\Collection Object
(
[items:protected] => Array
(
[0] => Array
(
[_id] => MongoDB\BSON\ObjectId Object
(
[oid] => 639e0f59889929ce620f4e9c
)
[id] => 35035
[availability] => In stock
[brand] => Bogas Primavara Vara
[condition] => new
[date_add] => 1671303001
[date_upd] => 1673865782
[description] => Rochie dama scurta catifea neagra Antonietta Bogas Rochie dama scurta catifea neagra Antonietta Bogas
[image_link] => https://www.bogas.ro/continut/produse/35035/1000/rochie-dama-scurta-catifea-neagra-antonietta-bogas_126777.jpeg
[link] => https://www.bogas.ro/rochie-dama-scurta-catifea-neagra-antonietta-bogas/?utm_source=googlemerchantcenter&utm_medium=cpc&utm_campaign=direct_link
[price] => 229.99 RON
[product_type] => Rochii
[sale_price] => 149.99 RON
[title] => Rochie dama scurta catifea neagra Antonietta Bogas
[update_history] => Array
(
[0] => Array
(
[id_feed] => 269
[feed_name] => bogas direct
[date_upd] => 1673865782
[field_history] => Array
(
)
)
)
[all_sizes] => Array
(
[0] => XS
[1] => S
[2] => M
[3] => L
[4] => XL
)
[sizes_out_of_stock] => Array
(
)
[additional_image_link] => Array
(
[0] => https://www.bogas.ro/continut/produse/35035/520/rochie-dama-scurta-catifea-neagra-antonietta-bogas_126775.jpeg
[1] => https://www.bogas.ro/continut/produse/35035/520/rochie-dama-scurta-catifea-neagra-antonietta-bogas_126776.jpeg
)
[all_attributes] => Array
(
[0] => Negru
[1] => Negru
[2] => Negru
[3] => Negru
[4] => Negru
)
[ean13] =>
[in_stock_attributes] => Array
(
[0] => Negru
[1] => Negru
[2] => Negru
[3] => Negru
[4] => Negru
)
[specs] => Array
(
[Material] => Catifea
)
[total_optiuni_out_of_stock] => Array
(
)
[clicks_last_30days_present] => 0
[field_update] => Array
(
[clicks_last_30days_present] => 1673872147
[cost_last_30days_present] => 1673872147
[conversions_last_30days_present] => 1673872147
[conversions_value_last_30days_present] => 1673872147
[impressions_last_30days_present] => 1673872147
[roas_last_30days_present] => 1673872147
)
[cost_last_30days_present] => 0
[conversions_last_30days_present] => 0
[conversions_value_last_30days_present] => 0
[impressions_last_30days_present] => 4
[roas_last_30days_present] => 0
)
)
[escapeWhenCastingToString:protected] =>
)
[perPage:protected] => 1
[currentPage:protected] => 1
[path:protected] => http://127.0.0.1:8000/api/price-monitor/matching/your-product/97-0048-2571-870/1
[query:protected] => Array
(
)
[fragment:protected] =>
[pageName:protected] => page
[onEachSide] => 3
[options:protected] => Array
(
[path] => http://127.0.0.1:8000/api/price-monitor/matching/your-product/97-0048-2571-870/1
[pageName] => page
)
[total:protected] => 830
[lastPage:protected] => 830
)
Now, I want to added a new array key with value to the output. So, I am doing this:
if( isset( $get_products[0]['additional_image_link'] ) && ! empty( $get_products[0]['additional_image_link'] ) ) {
$get_products[0]['carousel_images'] = $get_products[0]['additional_image_link'];
}
But I got an error message :
Indirect modification of overloaded element of
Illuminate\Pagination\LengthAwarePaginator has no effect

how to replace sub array

i get json in my project and then i have replace some sub array of it and again have to pass it. so, when i decode json and display it with pre tag it's display like this.
Array
(
[callid] => 59538ea658dfa
[action] => config_get
[message] => ok
[data] => Array
(
[config_file] => /cf/conf/config.xml
[config] => Array
(
[filter] => Array
(
[separator] => Array
(
[wan] =>
)
[rule] => Array
(
[0] => Array
(
[id] =>
[tracker] => 1498479412
[type] => pass
[interface] => wan
[ipprotocol] => inet
[tag] =>
[tagged] =>
[max] =>
[max-src-nodes] =>
[max-src-conn] =>
[max-src-states] =>
[statetimeout] =>
[statetype] => keep state
[os] =>
[protocol] => tcp
[source] => Array
(
[any] =>
)
[destination] => Array
(
[any] =>
)
[descr] => Hi manoj2
[updated] => Array
(
[time] => 1498479412
[username] => admin#172.16.1.22
)
[created] => Array
(
[time] => 1498479412
[username] => admin#172.16.1.22
)
)
[1] => Array
(
[statetype] => keep state
[statetimeout] =>
[max-src-states] =>
[max] =>
[tagged] =>
[tag] =>
[ipprotocol] => inet
[interface] => wan
[os] =>
[source] => Array
(
[any] =>
)
[destination] => Array
(
[any] =>
)
[descr] => hi Divyesh
[updated] => Array
(
[username] => admin#192.168.1.100
[time] => 1498301528
)
[created] => Array
(
[username] => admin#192.168.1.100
[time] => 1498301528
)
[type] => pass
[tracker] => 1498301528
[id] =>
[max-src-nodes] =>
[max-src-conn] =>
)
[2] => Array
(
[destination] => Array
(
[any] =>
)
[source] => Array
(
[network] => lan
)
[tracker] => 0100000101
[interface] => lan
[descr] => Default allow LAN to any rule
[ipprotocol] => inet
[type] => pass
)
[3] => Array
(
[destination] => Array
(
[any] =>
)
[source] => Array
(
[network] => lan
)
[tracker] => 0100000102
[interface] => lan
[descr] => Default allow LAN IPv6 to any rule
[ipprotocol] => inet6
[type] => pass
)
)
)
[shaper] =>
[ipsec] =>
[aliases] => Array
(
[alias] => Array
(
[0] => Array
(
[name] => manoj2_alias2
[type] => network
[address] => manoj2_alias3 172.30.2.65/16 172.30.2.51/32
[descr] => descc
[detail] => nfvbg||dfg||asd | asdfg
)
[1] => Array
(
[name] => manoj2_alias3
[type] => host
[address] => tyuty tyu
[descr] => dess
[detail] => tyu||tyu
)
[2] => Array
(
[name] => sdf
[type] => network
[address] => manoj2_alias2
[descr] => afsasf || weriojdg
[detail] => 256418
)
)
)
)
)
)
and i want to just replace portion sub array of [rule] with the.
[rule] => Array
(
[0] => Array
(
[id] =>
[tracker] => 1498479412
[type] => block
[interface] => lan
[ipprotocol] => any
[tag] =>
[tagged] =>
[max] =>
[max-src-nodes] =>
[max-src-conn] =>
[max-src-states] =>
[statetimeout] =>
[statetype] => keep state
[os] =>
[protocol] => tcp/udp
[source] => Array
(
[any] =>
)
[destination] => Array
(
[any] =>
)
[descr] => second option
[updated] => Array
(
[time] => 149844356
[username] => admin#172.16.1.22
)
[created] => Array
(
[time] => 1498479412
[username] => admin#172.16.1.22
)
)
[1] => Array
(
[statetype] => keep state
[statetimeout] =>
[max-src-states] =>
[max] =>
[tagged] =>
[tag] =>
[ipprotocol] => single
[interface] => wan
[os] =>
[source] => Array
(
[any] => 172.31.2.65/24
)
[destination] => Array
(
[any] => manoj2_alias2
)
[descr] => first option
[updated] => Array
(
[username] => admin#192.168.1.100
[time] => 1498301528
)
[created] => Array
(
[username] => admin#192.168.1.100
[time] => 1498301528
)
[type] => pass
[tracker] => 1498301528
[id] =>
[max-src-nodes] =>
[max-src-conn] =>
)
)
how to do it please help me. i tried but not any success.
Access your array element and assign the new array to it.
$array['data']['config']['filter']['rule'] = $theNewRuleArray;

Unset values from a multidimensional array from object

How can I unset all the setsystemtime elements from this array?
It's php version 4.4
This is the output of an instance inside my code:
2016-10-19T00:54:41-04:00 INFO (6): Array
(
[ * _bootstrap] => Bootstrap Object
(
[_appNamespace:protected] =>
[_resourceLoader:protected] =>
[_application:protected] => PEP_Application Object
(
[_autoloader:protected] => PEP_Autoloader Object
(
[_defaultAutoloader:protected] => Array
(
[0] => PEP_Loader
[1] => loadClass
)
[_fallbackAutoloader:protected] =>
[_internalAutoloader:protected] => Array
(
[0] => PEP_Autoloader Object
*RECURSION*
[1] => _autoload
)
[_namespaces:protected] => Array
(
[Zend_] => 1
[ZendX_] => 1
[WDPRO_] => 1
[PEP_] => 1
[controllers_helpers_] => 1
[Guzzle] => 1
[Symfony] => 1
)
[_suppressNotFoundWarnings:protected] =>
[_zfPath:protected] =>
)
[_bootstrap:protected] => Bootstrap Object
*RECURSION*
[_environment:protected] => local
[_optionKeys:protected] => Array
(
[0] => phpsettings
[1] => includepaths
[2] => bootstrap
[3] => resources
[4] => deviceprofiling
[5] => pluginpaths
[6] => autoloadernamespaces
)
[_options:protected] => Array
(
[resources] => Array
(
[frontController] => Array
(
[controllerDirectory] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/controllers
[moduleDirectory] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/modules
)
[layout] => Array
(
[layoutPath] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/layouts/scripts
)
[setsystemtime] => Array
(
[load] => 1
)
[session] => Array
(
[strict] => 1
)
[modules] => Array
(
[0] => api
[1] => trip
[2] => tickets
[3] => events
[4] => passes
[5] => plan
[6] => resortaddons
[7] => debugutils
[8] => visa-instant-credit
)
[view] =>
[log] => Array
(
[logConfig] => /configs/log.ini
)
[stats] => Array
(
[serviceLogLevel] => INFO
[requestResponseLogLevel] => DEBUG
[viewLogLevel] => INFO
[actionLogLevel] => INFO
[appLogLevel] => INFO
[memoryLogLevel] => DEBUG
)
[serviceSuccessLog] => Array
(
[logConfig] => /configs/serviceSuccessLog.ini
)
)
[deviceprofiling] => Array
(
[cookieName] => WDPROView
[timeToLive] => 604800
[cookiePath] => /
[enabled] => 1
[routeBlackList] => Array
(
[0] => /api
[1] => /utils
)
)
[pluginpaths] => Array
(
[PEP_Stats_Resource_] => PEP/Stats/Resource
[PEP_Application_Resource_] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/../library/PEP/Application/Resource
[Default_Resource_] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/resource
)
[autoloadernamespaces] => Array
(
[0] => WDPRO_
[1] => Zend_
[2] => PEP_
[3] => controllers_helpers_
[4] => Guzzle
[5] => Symfony
)
)
)
[_environment:protected] =>
[_optionKeys:protected] => Array
(
[0] => phpsettings
[1] => includepaths
[2] => bootstrap
[3] => resources
[4] => deviceprofiling
[5] => pluginpaths
[6] => autoloadernamespaces
)
[_options:protected] => Array
(
[phpSettings] => Array
(
[log_errors] => 1
[date] => Array
(
[timezone] => America/New_York
)
[display_startup_errors] => 0
[display_errors] => 1
[error_reporting] => 32767
[error_log] => C:\LodgingPhp\com-ui-php\target/logs/php_error.log
)
[includePaths] => Array
(
[library] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/../library
)
[bootstrap] => Array
(
[path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/Bootstrap.php
[class] => Bootstrap
)
[resources] => Array
(
[frontController] => Array
(
[controllerDirectory] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/controllers
[moduleDirectory] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/modules
)
[layout] => Array
(
[layoutPath] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/layouts/scripts
)
[setsystemtime] => Array
(
[load] => 1
)
[session] => Array
(
[strict] => 1
)
[modules] => Array
(
[0] => api
[1] => trip
[2] => tickets
[3] => events
[4] => passes
[5] => plan
[6] => resortaddons
[7] => debugutils
[8] => visa-instant-credit
)
[view] =>
[log] => Array
(
[logConfig] => /configs/log.ini
)
[stats] => Array
(
[serviceLogLevel] => INFO
[requestResponseLogLevel] => DEBUG
[viewLogLevel] => INFO
[actionLogLevel] => INFO
[appLogLevel] => INFO
[memoryLogLevel] => DEBUG
)
[serviceSuccessLog] => Array
(
[logConfig] => /configs/serviceSuccessLog.ini
)
)
[deviceprofiling] => Array
(
[cookieName] => WDPROView
[timeToLive] => 604800
[cookiePath] => /
[enabled] => 1
[routeBlackList] => Array
(
[0] => /api
[1] => /utils
)
)
[pluginpaths] => Array
(
[PEP_Stats_Resource_] => PEP/Stats/Resource
[PEP_Application_Resource_] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/../library/PEP/Application/Resource
[Default_Resource_] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/resource
)
[autoloadernamespaces] => Array
(
[0] => WDPRO_
[1] => Zend_
[2] => PEP_
[3] => controllers_helpers_
[4] => Guzzle
[5] => Symfony
)
)
[_pluginLoader:protected] =>
[_pluginResources:protected] => Array
(
[layout] => Array
(
[layoutPath] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/layouts/scripts
)
[setsystemtime] => Array
(
[load] => 1
)
[session] => Array
(
[strict] => 1
)
[modules] => Array
(
[0] => api
[1] => trip
[2] => tickets
[3] => events
[4] => passes
[5] => plan
[6] => resortaddons
[7] => debugutils
[8] => visa-instant-credit
)
[view] =>
[log] => Array
(
[logConfig] => /configs/log.ini
)
[stats] => Array
(
[serviceLogLevel] => INFO
[requestResponseLogLevel] => DEBUG
[viewLogLevel] => INFO
[actionLogLevel] => INFO
[appLogLevel] => INFO
[memoryLogLevel] => DEBUG
)
[serviceSuccessLog] => Array
(
[logConfig] => /configs/serviceSuccessLog.ini
)
[frontcontroller] => Zend_Application_Resource_Frontcontroller Object
(
[_front:protected] =>
[_bootstrap:protected] => Bootstrap Object
*RECURSION*
[_options:protected] => Array
(
[controllerDirectory] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/controllers
[moduleDirectory] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/modules
)
[_skipOptions:protected] => Array
(
[0] => options
[1] => config
)
)
)
[_run:protected] => Array
(
[0] => autoload
)
[_started:protected] => Array
(
[core] => 1
)
)
[ * _options] => Array
(
)
[ * _skipOptions] => Array
(
[0] => options
[1] => config
)
)
I tried with something like this and some variations for unset doesn't make the work... any idea?
foreach($a as $key => $b)
{
if($b == 'setsystemtime')
{
unset($a[$key]);
}
}
Looking for other answers I also try this:
foreach (array_keys($a, 'setsystemtime' , true) as $key) {
$logger->info('encontro a setsystem time!!!!!');
unset($a[$key]);
}
But never enters on it.
Thanks all!!

Remove an element from array PHP

Getting an instance like this:
$coreBootstrap = new PEP_Application_BootstrapCore(array('bootstrap' => $this));
Receives this object:
PEP_Application_BootstrapCore Object ( [_bootstrap:protected] => Bootstrap Object ( [_appNamespace:protected] => [_resourceLoader:protected] => [_application:protected] => PEP_Application Object ( [_autoloader:protected] => PEP_Autoloader Object ( [_autoloaders:protected] => Array ( [0] => Zend_Application_Module_Autoloader Object ( [_basePath:protected] => C:\LodgingPhp\com-ui-php\target\packaged-application\application [_components:protected] => Array ( [Default_Controller_Action_Helper] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/controllers/actions/helpers [Default_Module] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/modules [Default_Model_DbTable] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models/DbTable [Default_Model_Mapper] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models/mappers [Default_Form] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/forms [Default_Model] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models [Default_Plugin] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/plugins [Default_Service] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/services [Default_View_Helper] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/views/helpers [Default_View_Filter] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/views/filters ) [_defaultResourceType:protected] => model [_namespace:protected] => Default [_resourceTypes:protected] => Array ( [actionhelper] => Array ( [namespace] => Default_Controller_Action_Helper [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/controllers/actions/helpers ) [module] => Array ( [namespace] => Default_Module [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/modules ) [dbtable] => Array ( [namespace] => Default_Model_DbTable [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models/DbTable ) [mappers] => Array ( [namespace] => Default_Model_Mapper [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models/mappers ) [form] => Array ( [namespace] => Default_Form [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/forms ) [model] => Array ( [namespace] => Default_Model [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models ) [plugin] => Array ( [namespace] => Default_Plugin [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/plugins ) [service] => Array ( [namespace] => Default_Service [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/services ) [viewhelper] => Array ( [namespace] => Default_View_Helper [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/views/helpers ) [viewfilter] => Array ( [namespace] => Default_View_Filter [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/views/filters ) ) ) ) [_defaultAutoloader:protected] => Array ( [0] => PEP_Loader [1] => loadClass ) [_fallbackAutoloader:protected] => [_internalAutoloader:protected] => Array ( [0] => PEP_Autoloader Object *RECURSION* [1] => _autoload ) [_namespaces:protected] => Array ( [Zend_] => 1 [ZendX_] => 1 [WDPRO_] => 1 [PEP_] => 1 [controllers_helpers_] => 1 [Guzzle] => 1 [Symfony] => 1 ) [_namespaceAutoloaders:protected] => Array ( [Default_] => Array ( [0] => Zend_Application_Module_Autoloader Object ( [_basePath:protected] => C:\LodgingPhp\com-ui-php\target\packaged-application\application [_components:protected] => Array ( [Default_Controller_Action_Helper] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/controllers/actions/helpers [Default_Module] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/modules [Default_Model_DbTable] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models/DbTable [Default_Model_Mapper] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models/mappers [Default_Form] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/forms [Default_Model] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models [Default_Plugin] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/plugins [Default_Service] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/services [Default_View_Helper] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/views/helpers [Default_View_Filter] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/views/filters ) [_defaultResourceType:protected] => model [_namespace:protected] => Default [_resourceTypes:protected] => Array ( [actionhelper] => Array ( [namespace] => Default_Controller_Action_Helper [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/controllers/actions/helpers ) [module] => Array ( [namespace] => Default_Module [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/modules ) [dbtable] => Array ( [namespace] => Default_Model_DbTable [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models/DbTable ) [mappers] => Array ( [namespace] => Default_Model_Mapper [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models/mappers ) [form] => Array ( [namespace] => Default_Form [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/forms ) [model] => Array ( [namespace] => Default_Model [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models ) [plugin] => Array ( [namespace] => Default_Plugin [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/plugins ) [service] => Array ( [namespace] => Default_Service [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/services ) [viewhelper] => Array ( [namespace] => Default_View_Helper [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/views/helpers ) [viewfilter] => Array ( [namespace] => Default_View_Filter [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/views/filters ) ) ) ) ) [_suppressNotFoundWarnings:protected] => [_zfPath:protected] => ) [_bootstrap:protected] => Bootstrap Object *RECURSION* [_environment:protected] => local [_optionKeys:protected] => Array ( [0] => phpsettings [1] => includepaths [2] => bootstrap [3] => resources [4] => deviceprofiling [5] => pluginpaths [6] => autoloadernamespaces ) [_options:protected] => Array ( [phpSettings] => Array ( [log_errors] => 1 [date] => Array ( [timezone] => America/New_York ) [display_startup_errors] => 0 [display_errors] => 1 [error_reporting] => 32767 [error_log] => C:\LodgingPhp\com-ui-php\target/logs/php_error.log ) [includePaths] => Array ( [library] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/../library ) [bootstrap] => Array ( [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/Bootstrap.php [class] => Bootstrap ) [resources] => Array ( [frontController] => Array ( [controllerDirectory] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/controllers [moduleDirectory] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/modules ) [layout] => Array ( [layoutPath] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/layouts/scripts ) [setsystemtime] => Array ( [load] => ) [session] => Array ( [strict] => ) [modules] => Array ( [0] => api [1] => tickets [2] => events [3] => passes [4] => plan [5] => resortaddons [6] => debugutils [7] => visa-instant-credit ) [view] => [log] => Array ( [logConfig] => /configs/log.ini ) [stats] => Array ( [serviceLogLevel] => INFO [requestResponseLogLevel] => DEBUG [viewLogLevel] => INFO [actionLogLevel] => INFO [appLogLevel] => INFO [memoryLogLevel] => DEBUG ) [serviceSuccessLog] => Array ( [logConfig] => /configs/serviceSuccessLog.ini ) ) [deviceprofiling] => Array ( [cookieName] => WDPROView [timeToLive] => 604800 [cookiePath] => / [enabled] => 1 [routeBlackList] => Array ( [0] => /api [1] => /utils ) ) [pluginpaths] => Array ( [PEP_Stats_Resource_] => PEP/Stats/Resource [PEP_Application_Resource_] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/../library/PEP/Application/Resource [Default_Resource_] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/resource ) [autoloadernamespaces] => Array ( [0] => WDPRO_ [1] => Zend_ [2] => PEP_ [3] => controllers_helpers_ [4] => Guzzle [5] => Symfony ) ) ) [_classResources:protected] => Array ( [autoload] => _initAutoload [core] => _initCore [router] => _initRouter [servicestub] => _initServiceStub [mediaengineconfig] => _initMediaEngineConfig [viewhelpers] => _initViewHelpers [configurablestoreplugin] => _initConfigurableStorePlugin [languagesetupplugin] => _initLanguageSetupPlugin [keywordrouterplugin] => _initKeywordRouterPlugin [tripconfig] => _initTripConfig [dclkeepalive] => _initDclKeepAlive [helpconfig] => _initHelpConfig [analyticsgenericplugin] => _initAnalyticsGenericPlugin [postdispatchstatsdplugin] => _initPostDispatchStatsDPlugin [curoauthplugin] => _initCUROAuthPlugin [sessionserviceshdrplugin] => _initSessionServiceShdrPlugin ) [_container:protected] => Zend_Registry Object ( [storage:ArrayObject:private] => Array ( [autoload] => Zend_Application_Module_Autoloader Object ( [_basePath:protected] => C:\LodgingPhp\com-ui-php\target\packaged-application\application [_components:protected] => Array ( [Default_Controller_Action_Helper] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/controllers/actions/helpers [Default_Module] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/modules [Default_Model_DbTable] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models/DbTable [Default_Model_Mapper] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models/mappers [Default_Form] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/forms [Default_Model] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models [Default_Plugin] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/plugins [Default_Service] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/services [Default_View_Helper] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/views/helpers [Default_View_Filter] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/views/filters ) [_defaultResourceType:protected] => model [_namespace:protected] => Default [_resourceTypes:protected] => Array ( [actionhelper] => Array ( [namespace] => Default_Controller_Action_Helper [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/controllers/actions/helpers ) [module] => Array ( [namespace] => Default_Module [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/modules ) [dbtable] => Array ( [namespace] => Default_Model_DbTable [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models/DbTable ) [mappers] => Array ( [namespace] => Default_Model_Mapper [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models/mappers ) [form] => Array ( [namespace] => Default_Form [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/forms ) [model] => Array ( [namespace] => Default_Model [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/models ) [plugin] => Array ( [namespace] => Default_Plugin [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/plugins ) [service] => Array ( [namespace] => Default_Service [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/services ) [viewhelper] => Array ( [namespace] => Default_View_Helper [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/views/helpers ) [viewfilter] => Array ( [namespace] => Default_View_Filter [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/views/filters ) ) ) ) ) [_environment:protected] => [_optionKeys:protected] => Array ( [0] => phpsettings [1] => includepaths [2] => bootstrap [3] => resources [4] => deviceprofiling [5] => pluginpaths [6] => autoloadernamespaces ) [_options:protected] => Array ( [phpSettings] => Array ( [log_errors] => 1 [date] => Array ( [timezone] => America/New_York ) [display_startup_errors] => 0 [display_errors] => 1 [error_reporting] => 32767 [error_log] => C:\LodgingPhp\com-ui-php\target/logs/php_error.log ) [includePaths] => Array ( [library] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/../library ) [bootstrap] => Array ( [path] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/Bootstrap.php [class] => Bootstrap ) [resources] => Array ( [frontController] => Array ( [controllerDirectory] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/controllers [moduleDirectory] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/modules ) [layout] => Array ( [layoutPath] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/layouts/scripts ) [setsystemtime] => Array ( [load] => ) [session] => Array ( [strict] => ) [modules] => Array ( [0] => api [1] => tickets [2] => events [3] => passes [4] => plan [5] => resortaddons [6] => debugutils [7] => visa-instant-credit ) [view] => [log] => Array ( [logConfig] => /configs/log.ini ) [stats] => Array ( [serviceLogLevel] => INFO [requestResponseLogLevel] => DEBUG [viewLogLevel] => INFO [actionLogLevel] => INFO [appLogLevel] => INFO [memoryLogLevel] => DEBUG ) [serviceSuccessLog] => Array ( [logConfig] => /configs/serviceSuccessLog.ini ) ) [deviceprofiling] => Array ( [cookieName] => WDPROView [timeToLive] => 604800 [cookiePath] => / [enabled] => 1 [routeBlackList] => Array ( [0] => /api [1] => /utils ) ) [pluginpaths] => Array ( [PEP_Stats_Resource_] => PEP/Stats/Resource [PEP_Application_Resource_] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/../library/PEP/Application/Resource [Default_Resource_] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/resource ) [autoloadernamespaces] => Array ( [0] => WDPRO_ [1] => Zend_ [2] => PEP_ [3] => controllers_helpers_ [4] => Guzzle [5] => Symfony ) ) [_pluginLoader:protected] => [_pluginResources:protected] => Array ( [layout] => Array ( [layoutPath] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/layouts/scripts ) [setsystemtime] => Array ( [load] => ) [session] => Array ( [strict] => ) [modules] => Array ( [0] => api [1] => tickets [2] => events [3] => passes [4] => plan [5] => resortaddons [6] => debugutils [7] => visa-instant-credit ) [view] => [log] => Array ( [logConfig] => /configs/log.ini ) [stats] => Array ( [serviceLogLevel] => INFO [requestResponseLogLevel] => DEBUG [viewLogLevel] => INFO [actionLogLevel] => INFO [appLogLevel] => INFO [memoryLogLevel] => DEBUG ) [serviceSuccessLog] => Array ( [logConfig] => /configs/serviceSuccessLog.ini ) [frontcontroller] => Zend_Application_Resource_Frontcontroller Object ( [_front:protected] => [_bootstrap:protected] => Bootstrap Object *RECURSION* [_options:protected] => Array ( [controllerDirectory] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/controllers [moduleDirectory] => C:\LodgingPhp\com-ui-php\target\packaged-application\application/modules ) [_skipOptions:protected] => Array ( [0] => options [1] => config ) ) ) [_run:protected] => Array ( [0] => autoload ) [_started:protected] => Array ( [core] => 1 ) ) [_options:protected] => Array ( ) [_skipOptions:protected] => Array ( [0] => options [1] => config ) )
When I try:
$coreBootstrap = array_merge(array_diff($coreBootstrap, array('setsystemtime')));
I receive this message:
"array_merge(): Argument #1 is not an array in...."
I need to remove the setsystemtime, but I cannot reach it, I have tried also array_search but I get a similar error.
It's php 5.4.4
With the help obtained I figured that this is an object. I need that the part of the object 'setsystemtime' and their values get removed.
Any ideas?
Thank You!
You can cast the object as an array:
$coreBootstrap = array_merge(array_diff((array) $coreBootstrap, array('setsystemtime')));

Read object/array in PHP

I am working on Facebook leads API and successfully getting response for my lead
use FacebookAds\Object\Lead;
$form = new Lead('LEAD_ID');
$re = $form->read();
echo '<pre>';
print_r($re);
and the response is in following format :
FacebookAds\Object\Lead Object
(
[changedFields:protected] => Array
(
)
[api:protected] => FacebookAds\Api Object
(
[session:FacebookAds\Api:private] => FacebookAds\Session Object
(
[appId:protected] => 448283968712152
[appSecret:protected] => 0cf8998603f3050f9d80ded4cecdb7f7
[accessToken:protected] => EAAGXtj62rdgBAP0ZCjmnddu3ZBIgZAECUluzPL6CGUuZB07tPUlERk4L1iRb2gy31qlUx2ExBENZBegpvfHxmxsJYks8rghrKOZBHMWEblEgsIvo5GF3ySzbyVszg7lbYIuBSgeFdzAMq6GuW6iZCQrgXd4KfAVoiQZD
[appSecretProof:protected] => c6112ce522414623dea1fb41cc29f6f15ca480845b8490d7c45ec67a485fa3f6
)
[logger:protected] => FacebookAds\Logger\NullLogger Object
(
)
[httpClient:protected] => FacebookAds\Http\Client Object
(
[requestPrototype:protected] => FacebookAds\Http\Request Object
(
[client:protected] => FacebookAds\Http\Client Object
*RECURSION*
[headers:protected] =>
[method:protected] => GET
[protocol:protected] => https://
[domain:protected] =>
[path:protected] =>
[graphVersion:protected] =>
[queryParams:protected] =>
[bodyParams:protected] =>
[fileParams:protected] =>
)
[responsePrototype:protected] => FacebookAds\Http\Response Object
(
[request:protected] =>
[statusCode:protected] =>
[headers:protected] =>
[body:protected] =>
[content:protected] =>
)
[defaultRequestHeaders:protected] => FacebookAds\Http\Headers Object
(
[storage:ArrayObject:private] => Array
(
[User-Agent] => fb-php-ads-2.5.1
[Accept-Encoding] => *
)
)
[adapter:protected] => FacebookAds\Http\Adapter\CurlAdapter Object
(
[curl:protected] => FacebookAds\Http\Adapter\Curl\Curl Object
(
[handle:protected] => Resource id #34
)
[opts:protected] => ArrayObject Object
(
[storage:ArrayObject:private] => Array
(
[78] => 10
[13] => 60
[19913] => 1
[42] => 1
[10065] => /home/leadsgeneration/public_html/v1/vendor/facebook/php-ads-sdk/src/FacebookAds/Http/../../../fb_ca_chain_bundle.crt
)
)
[client:protected] => FacebookAds\Http\Client Object
*RECURSION*
)
[caBundlePath:protected] => /home/leadsgeneration/public_html/v1/vendor/facebook/php-ads-sdk/src/FacebookAds/Http/../../../fb_ca_chain_bundle.crt
[defaultGraphBaseDomain:protected] => facebook.com
)
[defaultGraphVersion:protected] => 2.5
)
[parentId:protected] =>
[data:protected] => Array
(
[ad_id] =>
[adset_id] =>
[campaign_id] =>
[created_time] => 2016-04-18T04:17:55+0000
[field_data] => Array
(
[0] => Array
(
[name] => email
[values] => Array
(
[0] => varunroute69#gmail.com
)
)
[1] => Array
(
[name] => phone_number
[values] => Array
(
[0] => +919731688688
)
)
[2] => Array
(
[name] => full_name
[values] => Array
(
[0] => Varun Majety
)
)
)
[form_id] =>
[id] => 571052196402628
[post] =>
)
)
I want to store [data:protected][field_data] in database so i want to read this array but when i try to echo like echo '-->'.$re['FacebookAds\Object\Lead Object']['data:protected'][field_data][0]['name']; it throws me an error.
How to read the above format?Any help would be greatly appreciated.
$form = new \FacebookAds\Object\Lead('LEAD_ID');
$form->read();
echo '<pre>';
print_r($form->getData());
Will give you
Array
(
[ad_id] =>
[ad_name] =>
[adset_id] =>
[adset_name] =>
[campaign_id] =>
[campaign_name] =>
[created_time] => 2016-09-18T06:57:13+0000
[custom_disclaimer_responses] =>
[field_data] => Array
(
[0] => Array
(
[name] => full_name
[values] => Array
(
[0] =>
)
)
[1] => Array
(
[name] => email
[values] => Array
(
[0] => test#fb.com
)
)
[2] => Array
(
[name] => phone_number
[values] => Array
(
[0] =>
)
)
)
[form_id] =>
[id] => 1681384948848301
[is_organic] =>
[post] =>
)

Categories