Php version:
enter image description here
When I request one of the interface of my CodeIgniter project and echo phpinfo(), there is no redis extension in the message.And the project loaded the wrong version of php like:
enter image description here
Yes I have multiple version of php in my MacOS.
Can anyone help me with this?
My project has this error msg:
ERROR - 2019-01-09 04:18:05 --> Exception:Error::__set_state(array(
'message' => 'Class \'Redis\' not found',
'string' => '',
'code' => 0,
'file' => '/Users/charlie/IdeaProjects/my_project/src/application/libraries/My_Redis.php',
'line' => 93,
'trace' =>
array (
0 =>
array (
'file' => '/Users/charlie/IdeaProjects/my_project/src/application/libraries/My_Redis.php',
'line' => 51,
'function' => '_init',
'class' => 'My_Redis',
'type' => '->',
'args' =>
array (
0 =>
array (
'host' => '',
'port' => 6379,
'password' => '',
'timeout' => 2,
'persistent' => 0,
),
),
),
1 =>
array (
'file' => '/Users/charlie/IdeaProjects/my_project/src/application/libraries/My_Redis.php',
'line' => 35,
'function' => 'getInstance',
'class' => 'My_Redis',
'type' => '->',
'args' =>
array (
0 => 'supply_chain_busi',
),
),
2 =>
array (
'file' => '/Users/charlie/IdeaProjects/my_project/src/system/core/Loader.php',
'line' => 1095,
'function' => '__construct',
'class' => 'My_Redis',
'type' => '->',
'args' =>
array (
0 => 'supply_chain_busi',
),
),
3 =>
array (
'file' => '/Users/charlie/IdeaProjects/my_project/src/system/core/Loader.php',
'line' => 975,
'function' => '_ci_init_class',
'class' => 'CI_Loader',
'type' => '->',
'args' =>
array (
0 => 'my_redis',
1 => '',
2 =>
array (
0 => 'supply_chain_busi',
),
3 => 'redis',
),
),
4 =>
array (
'file' => '/Users/charlie/IdeaProjects/my_project/src/system/core/Loader.php',
'line' => 216,
'function' => '_ci_load_class',
'class' => 'CI_Loader',
'type' => '->',
'args' =>
array (
0 => 'My_Redis',
1 =>
array (
0 => 'supply_chain_busi',
),
2 => 'redis',
),
),
5 =>
array (
'file' => '/Users/charlie/IdeaProjects/my_project/src/application/libraries/Tank_auth.php',
'line' => 45,
'function' => 'library',
'class' => 'CI_Loader',
'type' => '->',
'args' =>
array (
0 => 'My_Redis',
1 =>
array (
0 => 'supply_chain_busi',
),
2 => 'redis',
),
),
6 =>
array (
'file' => '/Users/charlie/IdeaProjects/my_project/src/system/core/Loader.php',
'line' => 1095,
'function' => '__construct',
'class' => 'Tank_auth',
'type' => '->',
'args' =>
array (
0 =>
array (
'website_name' => 'mycom',
'webmaster_email' => 'webmaster#mycom.com',
'phpass_hash_portable' => true,
'phpass_hash_strength' => 8,
'allow_registration' => false,
'captcha_registration' => false,
'email_activation' => false,
'email_activation_expire' => 172800,
'email_account_details' => true,
'use_username' => true,
'username_min_length' => 4,
'username_max_length' => 20,
'password_min_length' => 4,
'password_max_length' => 20,
'login_by_username' => true,
'login_by_email' => true,
'login_record_ip' => true,
'login_record_time' => true,
'login_count_attempts' => true,
'login_max_attempts' => 99,
'login_attempt_expire' => 86400,
'autologin_cookie_name' => 'autologin',
'autologin_cookie_life' => 2592000,
'forgot_password_expire' => 900,
'captcha_path' => 'captcha/',
'captcha_fonts_path' => 'captcha/fonts/5.ttf',
'captcha_width' => 200,
'captcha_height' => 50,
'captcha_font_size' => 14,
'captcha_grid' => false,
'captcha_expire' => 180,
'captcha_case_sensitive' => false,
'use_recaptcha' => false,
'recaptcha_public_key' => '',
'recaptcha_private_key' => '',
'db_table_prefix' => '',
),
),
),
7 =>
array (
'file' => '/Users/charlie/IdeaProjects/my_project/src/system/core/Loader.php',
'line' => 975,
'function' => '_ci_init_class',
'class' => 'CI_Loader',
'type' => '->',
'args' =>
array (
0 => 'tank_auth',
1 => '',
2 =>
array (
'website_name' => 'mycom',
'webmaster_email' => 'webmaster#mycom.com',
'phpass_hash_portable' => true,
'phpass_hash_strength' => 8,
'allow_registration' => false,
'captcha_registration' => false,
'email_activation' => false,
'email_activation_expire' => 172800,
'email_account_details' => true,
'use_username' => true,
'username_min_length' => 4,
'username_max_length' => 20,
'password_min_length' => 4,
'password_max_length' => 20,
'login_by_username' => true,
'login_by_email' => true,
'login_record_ip' => true,
'login_record_time' => true,
'login_count_attempts' => true,
'login_max_attempts' => 99,
'login_attempt_expire' => 86400,
'autologin_cookie_name' => 'autologin',
'autologin_cookie_life' => 2592000,
'forgot_password_expire' => 900,
'captcha_path' => 'captcha/',
'captcha_fonts_path' => 'captcha/fonts/5.ttf',
'captcha_width' => 200,
'captcha_height' => 50,
'captcha_font_size' => 14,
'captcha_grid' => false,
'captcha_expire' => 180,
'captcha_case_sensitive' => false,
'use_recaptcha' => false,
'recaptcha_public_key' => '',
'recaptcha_private_key' => '',
'db_table_prefix' => '',
),
3 => NULL,
),
),
8 =>
array (
'file' => '/Users/charlie/IdeaProjects/my_project/src/system/core/Loader.php',
'line' => 216,
'function' => '_ci_load_class',
'class' => 'CI_Loader',
'type' => '->',
'args' =>
array (
0 => 'Tank_auth',
1 => NULL,
2 => NULL,
),
),
9 =>
array (
'file' => '/Users/charlie/IdeaProjects/my_project/src/system/core/Loader.php',
'line' => 1178,
'function' => 'library',
'class' => 'CI_Loader',
'type' => '->',
'args' =>
array (
0 => 'Tank_auth',
),
),
10 =>
array (
'file' => '/Users/charlie/IdeaProjects/my_project/src/system/core/Loader.php',
'line' => 152,
'function' => '_ci_autoloader',
'class' => 'CI_Loader',
'type' => '->',
'args' =>
array (
),
),
11 =>
array (
'file' => '/Users/charlie/IdeaProjects/my_project/src/system/core/Controller.php',
'line' => 51,
'function' => 'initialize',
'class' => 'CI_Loader',
'type' => '->',
'args' =>
array (
),
),
12 =>
array (
'file' => '/Users/charlie/IdeaProjects/my_project/src/application/libraries/REST_Controller.php',
'line' => 197,
'function' => '__construct',
'class' => 'CI_Controller',
'type' => '->',
'args' =>
array (
),
),
13 =>
array (
'file' => '/Users/charlie/IdeaProjects/my_project/src/application/controllers/api/my_project.php',
'line' => 11,
'function' => '__construct',
'class' => 'REST_Controller',
'type' => '->',
'args' =>
array (
),
),
14 =>
array (
'file' => '/Users/charlie/IdeaProjects/my_project/src/system/core/CodeIgniter.php',
'line' => 310,
'function' => '__construct',
'class' => 'my_project',
'type' => '->',
'args' =>
array (
),
),
15 =>
array (
'file' => '/Users/charlie/IdeaProjects/my_project/src/index.php',
'line' => 204,
'args' =>
array (
0 => '/Users/charlie/IdeaProjects/my_project/src/system/core/CodeIgniter.php',
),
'function' => 'require_once',
),
),
'previous' => NULL,
))
The rest of the log is similar.It just cant find the Redis class.
Ok,finally I solved it.Just install it with brew:
*brew install --without-apache --with-fpm --with-mysql --with-redis --with-curl --with-intl --with-iconv php72
echo 'export PATH="/usr/local/opt/php#7.2/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/php#7.2/sbin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
*
I dont know if these options are right but I did have my php installed properly with all the exts I need.
Related
I'd like to return the value of the Birthday field from the following massive mixed array of data containing nested arrays and stdClass Objects. I tried the following code but it didn't work, I would be extremely grateful for any help.
$data->_field_data['nid']['entity']->field_player_birthday['und'][0]['value'];
PHP:
stdClass::__set_state(array(
'node_field_data_field_game_players_nid' => '2931',
'node_title' => '1539634465',
'nid' => '8114',
'node_language' => 'tr',
'field_data_field_player_birthday_node_entity_type' => 'node',
'_field_data' => array (
'node_field_data_field_game_players_nid' => array (
'entity_type' => 'node',
'entity' => stdClass::__set_state(
array( 'vid' => '2931',
'uid' => '1',
'title' => 'Fernando Muslera',
'log' => '',
'status' => '1',
'comment' => '1',
'promote' => '0',
'sticky' => '0',
'ds_switch' => '',
'nid' => '2931',
'type' => 'player',
'language' => 'und',
'created' => '1520727843',
'changed' => '1539137801',
'tnid' => '0',
'translate' => '0',
'revision_timestamp' => '1539137801',
'revision_uid' => '1',
'body' =>
array ( ), 'field_player_address' => array ( 'und' => array ( 0 =>
array ( 'country' => 'AR', 'administrative_area' => 'B',
'sub_administrative_area' => NULL, 'locality' => 'Buenos Aires',
'dependent_locality' => '', 'postal_code' => '', 'thoroughfare' => '',
'premise' => '', 'sub_premise' => NULL, 'organisation_name' => NULL,
'name_line' => NULL, 'first_name' => NULL, 'last_name' => NULL, 'data'
=> NULL, ), ), ), 'field_geofield' => array ( 'und' => array ( 0 => array ( 'geom' => 'POINT (-58.3815591 -34.6036844)', 'geo_type' =>
'point', 'lat' => '-34.603684400000', 'lon' => '-58.381559100000',
'left' => '-58.381559100000', 'top' => '-34.603684400000', 'right' =>
'-58.381559100000', 'bottom' => '-34.603684400000', 'geohash' =>
'69y7pkxfgjdq4', ), ), ), 'field_player_search_news' => array ( ),
'field_player_map' => array ( ), 'field_player_birthday' => array (
'und' => array ( 0 => array ( 'value' => '1986-06-16 00:00:00',
'timezone' => 'America/New_York', 'timezone_db' => 'America/New_York',
'date_type' => 'datetime', ), ), ), 'field_player_team' => array (
'und' => array ( 0 => array ( 'tid' => '328', ), ), ), 'field_image'
=> array ( ), 'field_game_rating' => array ( 'und' => array ( 0 => array ( 'rating' => '90', 'target' => NULL, ), ), ), 'rdf_mapping' =>
array ( 'rdftype' => array ( 0 => 'sioc:Item', 1 => 'foaf:Document',
), 'title' => array ( 'predicates' => array ( 0 => 'dc:title', ), ),
'created' => array ( 'predicates' => array ( 0 => 'dc:date', 1 =>
'dc:created', ), 'datatype' => 'xsd:dateTime', 'callback' =>
'date_iso8601', ), 'changed' => array ( 'predicates' => array ( 0 =>
'dc:modified', ), 'datatype' => 'xsd:dateTime', 'callback' =>
'date_iso8601', ), 'body' => array ( 'predicates' => array ( 0 =>
'content:encoded', ), ), 'uid' => array ( 'predicates' => array ( 0 =>
'sioc:has_creator', ), 'type' => 'rel', ), 'name' => array (
'predicates' => array ( 0 => 'foaf:name', ), ), 'comment_count' =>
array ( 'predicates' => array ( 0 => 'sioc:num_replies', ), 'datatype'
=> 'xsd:integer', ), 'last_activity' => array ( 'predicates' => array ( 0 => 'sioc:last_activity_date', ), 'datatype' => 'xsd:dateTime',
'callback' => 'date_iso8601', ), ), 'path' => array ( 'pathauto' =>
'1', ), 'cid' => '0', 'last_comment_timestamp' => '1520727843',
'last_comment_name' => NULL, 'last_comment_uid' => '1',
'comment_count' => '0', 'name' => 'efet', 'picture' => '0', 'data' =>
'a:7:{s:7:"contact";i:1;s:5:"block";a:1:{s:6:"system";a:1:{s:4:"main";i:1;}}s:16:"ckeditor_default";s:1:"t";s:20:"ckeditor_show_toggle";s:1:"t";s:14:"ckeditor_width";s:4:"100%";s:13:"ckeditor_lang";s:2:"en";s:18:"ckeditor_auto_lang";s:1:"t";}',
)), ), ), 'field_field_player_birthday' => array ( 0 => array (
'rendered' => array ( '#markup' => '1986', '#access' => true, ), 'raw'
=> array ( 'value' => '1986-06-16 00:00:00', 'timezone' => America/New_York', 'timezone_db' => 'America/New_York', 'date_type'
> => 'datetime', ), ), ), ))
You are close (as I've had to change the objects slightly to test, I hope this works)...
echo $data->_field_data['node_field_data_field_game_players_nid']['entity']
->field_player_birthday['und'][0]['value'];
Basically instead of nid, it's node_field_data_field_game_players_nid.
I'm doing the exact steps of the following answer:
https://stackoverflow.com/a/16731438
However, if I switch to Manual Configuration I got the following error, even if my realurl_conf.php is the exact same file as realurl_autoconf.php was before:
Page Not Found
Reason: Segment "fotografie" was not a keyword for a postVarSet as expected on page with id=0.
If I switch back to automatic config everything works as expected.
Any ideas on that?
TYPO3 7.6.11
Here is the realurl_autoconf.php:
<?php
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']=array (
'brightfocus.de' =>
array (
'init' =>
array (
'appendMissingSlash' => 'ifNotFile,redirect',
'emptyUrlReturnValue' => '/',
),
'pagePath' =>
array (
'rootpage_id' => '1',
),
'fileName' =>
array (
'defaultToHTMLsuffixOnPrev' => 0,
'acceptHTMLsuffix' => 1,
'index' =>
array (
'print' =>
array (
'keyValues' =>
array (
'type' => 98,
),
),
),
),
'postVarSets' =>
array (
'_DEFAULT' =>
array (
't3extblog-action' =>
array (
0 =>
array (
'GETvar' => 'tx_t3extblog_blogsystem[action]',
'noMatch' => 'bypass',
),
),
'article' =>
array (
0 =>
array (
'GETvar' => 'tx_t3extblog_blogsystem[year]',
),
1 =>
array (
'GETvar' => 'tx_t3extblog_blogsystem[month]',
),
2 =>
array (
'GETvar' => 'tx_t3extblog_blogsystem[day]',
),
3 =>
array (
'GETvar' => 'tx_t3extblog_blogsystem[post]',
'lookUpTable' =>
array (
'table' => 'tx_t3blog_post',
'id_field' => 'uid',
'alias_field' => 'title',
'addWhereClause' => ' AND NOT deleted AND NOT hidden',
'useUniqueCache' => 1,
'useUniqueCache_conf' =>
array (
'strtolower' => 1,
'spaceCharacter' => '-',
),
'enable404forInvalidAlias' => 1,
'autoUpdate' => 1,
'expireDays' => 180,
'languageGetVar' => 'L',
'languageExceptionUids' => '',
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l18n_parent',
),
),
),
'comment' =>
array (
0 =>
array (
'GETvar' => 'tx_t3extblog_blogsystem[controller]',
'noMatch' => 'bypass',
'valueMap' =>
array (
'new' => 'Comment',
),
),
),
'permalink' =>
array (
0 =>
array (
'GETvar' => 'tx_t3extblog_blogsystem[permalinkPost]',
),
),
'preview' =>
array (
0 =>
array (
'GETvar' => 'tx_t3extblog_blogsystem[previewPost]',
),
),
'author' =>
array (
0 =>
array (
'GETvar' => 'tx_t3extblog_blogsystem[author]',
'lookUpTable' =>
array (
'table' => 'be_users',
'id_field' => 'uid',
'alias_field' => 'username',
'addWhereClause' => ' AND deleted !=1 AND disable !=1',
'useUniqueCache' => 1,
'useUniqueCache_conf' =>
array (
'strtolower' => 1,
'spaceCharacter' => '-',
),
'enable404forInvalidAlias' => 1,
'autoUpdate' => 1,
'expireDays' => 180,
),
),
),
'tags' =>
array (
0 =>
array (
'GETvar' => 'tx_t3extblog_blogsystem[tag]',
),
),
'category' =>
array (
0 =>
array (
'GETvar' => 'tx_t3extblog_blogsystem[category]',
'lookUpTable' =>
array (
'table' => 'tx_t3blog_cat',
'id_field' => 'uid',
'alias_field' => 'catname',
'addWhereClause' => ' AND deleted !=1 AND hidden !=1',
'useUniqueCache' => 1,
'useUniqueCache_conf' =>
array (
'strtolower' => 1,
'spaceCharacter' => '-',
),
'enable404forInvalidAlias' => 1,
'autoUpdate' => 1,
'expireDays' => 180,
'languageGetVar' => 'L',
'languageExceptionUids' => '',
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l18n_parent',
),
),
),
'page' =>
array (
0 =>
array (
'GETvar' => 'tx_t3extblog_blogsystem[#widget_0][currentPage]',
),
),
'subscription' =>
array (
0 =>
array (
'GETvar' => 'tx_t3extblog_subscriptionmanager[controller]',
'valueMap' =>
array (
'blog' => 'BlogSubscriber',
'post' => 'PostSubscriber',
),
'noMatch' => 'bypass',
),
1 =>
array (
'GETvar' => 'tx_t3extblog_subscriptionmanager[action]',
'valueMap' =>
array (
'confirmation' => 'confirm',
'create' => 'create',
'delete' => 'delete',
'error' => 'error',
'logout' => 'logout',
),
'noMatch' => 'bypass',
),
2 =>
array (
'GETvar' => 'tx_t3extblog_subscriptionmanager[code]',
),
),
'subscription-blog' =>
array (
0 =>
array (
'GETvar' => 'tx_t3extblog_blogsubscription[action]',
),
),
),
),
),
);
Edit:
Maybe there is something wrong with the rootpageId:
If i edit the autoconf from rootpage id 1 to rootpage id 2 i get the following error:
Page Not Found
Reason: Segment "fotografie" was not a keyword for a postVarSet as expected on page with id=2.
=> I assume the part id=2 comes from my rootpageId. Going back to my original error, i assume there is somehow a rootpageId of 0 specified (even if set rootpage_id = '1'
I have the following site structure:
id=0
|id=1 (Home; Redirect to id=2; marked as rootpage)
-|id=2 (Startseite)
-|id=3 (Fotografie)
-|id=4 (Grafikdesign)
I know this is not ideal, but with autoconf this structure is working, so i assume there must be a way to get this working with manual conf, without changig the structure (because i don't think this would be trivial)
Try this very minimal config: The rootpage is defined also the domainname, this may work, but I always have trouble with realurl on diffeerent types of domain (local/sub/nregular) and caching of paths.
Paths cache can be flushed in the backend: Web > Speaking URL's > "select a page in tree" > Flush all Entries (harmful). Dont do this on an indexed site!
Hope this config works for you.
<?php
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'] = array (
'_DEFAULT' => array (
'init' => array (
'enableCHashCache' => '1',
'appendMissingSlash' => 'ifNotFile',
'enableUrlDecodeCache' => '1',
'enableUrlEncodeCache' => '1',
),
'redirects' => array (
),
'pagePath' => array (
'type' => 'user',
'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
'spaceCharacter' => '-',
'languageGetVar' => 'L',
'expireDays' => '7',
'rootpage_id' => $rootpageId,
),
),
);
switch($_SERVER['HTTP_HOST']) {
case 'yourwebsite.com':
case 'www.yourwebsite.com':
$TYPO3_CONF_VARS['FE']['pageNotFound_handling'] = 'index.php?id=4';
$TYPO3_CONF_VARS['FE']['pageNotFound_handling_statheader'] = 'HTTP/1.0 404 Not Found';
$rootpageId = 1;
break;
}
?>
I need to Search collection in mongodb having
'food_name' => 'fish'
and
'room_features' =>
array (
0 => 'Shower',
1 => 'Hairdryer',
),
I tried the following code. But the result is not-correct. I think multiple $eq is not allowed (same index in array).
array (
'$and' =>
array (
array (
'food' =>
array (
'$elemMatch' =>
array (
'food_name' =>
array (
'$eq' => 'fish',
),
),
),
),
array (
'room' =>
array (
'$elemMatch' =>
array (
'room_features' =>
array (
'$elemMatch' =>
array (
'$eq' => 'Shower'
'$eq' => 'Hairdryer'
),
),
'roomrate' =>
array (
'$eq' => new MongoInt32(2500),
),
),
),
),
),
)
Here is the document I need to search.
array (
'_id' => new MongoId("59670aca7fafd8342e3c9869"),
'subcat_name' => 'Test',
'place' => '',
'description' => '',
'created_date' => '1499970060',
'created_by' => 'Admin',
'openingtime' => '',
'closingtime' => '',
'hotel_class_id' => '594245f67fafd87e243c986a',
'hotel_type_id' => '594244177fafd884563c9869',
'latitude' => '0',
'longitude' => '0',
'dist_id' => '5911966a7fafd8c83c3c986a',
'cat_id' => '58fb230e7fafd883183c986d',
'featured' => '0',
'visited' => new MongoInt64(5),
'subcat_slug' => 'test-trivandrum-1',
'image' => NULL,
'food' =>
array (
0 =>
array (
'food_id' => '149992634012642164',
'region_id' => '5944ba947fafd883333c9869',
'food_name' => 'fish',
'type' => 'veg',
'rate' => '100',
),
1 =>
array (
'food_id' => '14999366891994980639',
'region_id' => '595c75c17fafd835173c986c',
'food_name' => 'curry',
'type' => 'veg',
'rate' => '1000',
),
),
'room' =>
array (
0 =>
array (
'room_id' => '14999346791721342880',
'roomtype' => 'DELUXE KING ROOM1',
'roomrate' => new MongoInt64(2500),
'image' => 'beach_icon33.png',
'room_features' =>
array (
0 => 'Shower',
1 => 'Hairdryer',
),
),
1 =>
array (
'room_id' => '14999346901389554873',
'roomtype' => 'DELUXE KING ROOM new',
'roomrate' => new MongoInt64(4000),
'image' => 'beach_icon34.png',
'room_features' =>
array (
0 => 'Shower',
1 => 'Bathrobe',
),
),
),
)
Please Give me an alternate way to search multiple item from array.
Thanks in advance.
I think if you want to query list you can add the list in query,
try this
{
"food" : {
"$elemMatch": {
"food_name" : "fish"
}
},
"room" : {
"$elemMatch": {
"room_features" : ["Shower", "Hairdryer"]
}
},
}
Hope this help.
I'm playing around with the twitter API and i'm trying to parse the json output. However somehow i'm doing something wrong and I'm not getting what I would like to get.
In this case i'm writing in PHP. Started looping thru the array and screen_name and text are working accordingly.
foreach ($statuses as $obj) {
$screen_name = filter_var($obj->user->screen_name, FILTER_SANITIZE_STRING);
$text = filter_var($obj->text, FILTER_SANITIZE_STRING);
$urls = filter_var($obj->entities->urls->url, FILTER_SANITIZE_URL);
}
the JSON array output:
array (
0 =>
stdClass::__set_state(array(
'created_at' => 'Fri Oct 07 15:31:01 +0000 2016',
'text' => 'test',
'entities' =>
stdClass::__set_state(array(
'hashtags' =>
array (
0 =>
stdClass::__set_state(array(
'text' => '30Under30',
'indices' =>
array (
0 => 36,
1 => 46,
),
)),
),
'symbols' =>
array (
),
'user_mentions' =>
array (
),
'urls' =>
array (
0 =>
stdClass::__set_state(array(
'url' => 'https://Forbes.com',
'expanded_url' => 'https://twitter.com/i/web/status/784415744427687936',
'display_url' => 'twitter.com/i/web/status/7…',
'indices' =>
array (
0 => 117,
1 => 140,
),
)),
),
)),
'source' => 'Sprinklr',
'in_reply_to_screen_name' => NULL,
'user' =>
stdClass::__set_state(array(
'id' => 91478624,
'screen_name' => 'test',
'url' => 'http://Forbes.com',
'entities' =>
stdClass::__set_state(array(
'url' =>
stdClass::__set_state(array(
'urls' =>
array (
0 =>
stdClass::__set_state(array(
'url' => 'http://Forbes.com',
'expanded_url' => 'http://forbes.com',
'display_url' => 'forbes.com',
'indices' =>
array (
0 => 0,
1 => 22,
),
)),
),
)),
'description' =>
stdClass::__set_state(array(
'urls' =>
array (
0 =>
stdClass::__set_state(array(
'url' => 'http://Forbes.com',
'expanded_url' => 'http://Forbes.com',
'display_url' => 'Forbes.com',
'indices' =>
array (
0 => 28,
1 => 48,
),
)),
),
)),
)),
'protected' => false,
'notifications' => false,
)),
'geo' => NULL,
'lang' => 'en',
)),
)
Since urls is an array, you need to index it.
$urls = filter_var($obj->entities->urls[0]->url, FILTER_SANITIZE_URL);
I am currently stuck on the modification of an array "flat" to a array structure of a tree.
I have an array to the type:
$folders = array(
array('Name' => 'Archive', 'Value' => 'Archive', 'Attributes' => 32, 'Delimiters' => '/'),
array('Name' => 'Folder1', 'Value' => 'Archive/Folder1', 'Attributes' => 32, 'Delimiters' => '/'),
array('Name' => 'FolderA', 'Value' => 'Archive/Folder1/DossierA', 'Attributes' => 64, 'Delimiters' => '/'),
array('Name' => 'Folder2', 'Value' => 'Archive/Folder2', 'Attributes' => 32, 'Delimiters' => '/'),
array('Name' => 'FolderA', 'Value' => 'Archive/Folder2/FolderA', 'Attributes' => 32, 'Delimiters' => '/'),
array('Name' => 'FolderB', 'Value' => 'Archive/Folder2/FolderA/FolderB', 'Attributes' => 64, 'Delimiters' => '/'),
);
and I would get an array to the type:
$treefolders = array(
array('Name' => 'Archive', 'Value' => 'Archive', 'Attributes' => 32, 'Delimiters' => '/', 'subnode' =>
array('Name' => 'Folder1', 'Value' => 'Archive/Folder1', 'Attributes' => 32, 'Delimiters' => '/', 'subnode' =>
array('Name' => 'FolderA', 'Value' => 'Archive/Folder1/FolderA', 'Attributes' => 64, 'Delimiters' => '/')
),
array('Name' => 'Folder2', 'Value' => 'Archive/Folder2', 'Attributes' => 32, 'Delimiters' => '/', 'subnode' =>
array('Name' => 'FolderA', 'Value' => 'Archive/Folder2/FolderA', 'Attributes' => 32, 'Delimiters' => '/', 'subnode' =>
array('Name' => 'FolderB', 'Value' => 'Archive/Folder2/FolderA/FolderB', 'Attributes' => 64, 'Delimiters' => '/')
)
)
)
);
I do not know how to get to the last result.
Can you help me?
This is not possible, in PHP arrays cannot be used as array keys. You are able to use just the directory name as a key.
The best solution is to change the way you create your array or rethink your code and/or data structure. There is probably a much easier solution to your problem, maybe re-ask your question. See the XY problem.
Sorry I have done anything in my first post
Here is the structure of my array "flat":
Array
(
[0] =>
Array
(
'Name' => 'Archive'
'Value' => 'Archive'
'Attributes' => 32
'Delimiters' => '/'
)
[1] =>
Array
(
'Name' => 'Folder1'
'Value' => 'Archive/Folder1'
'Attributes' => 32
'Delimiters' => '/'
)
[2] =>
Array
(
'Name' => 'FolderA'
'Value' => 'Archive/Folder1/DossierA'
'Attributes' => 64
'Delimiters' => '/'
)
[3] =>
Array
(
'Name' => 'Folder2'
'Value' => 'Archive/Folder2'
'Attributes' => 32
'Delimiters' => '/'
)
[4] =>
Array
(
'Name' => 'FolderA'
'Value' => 'Archive/Folder2/FolderA'
'Attributes' => 32
'Delimiters' => '/'
)
[5] =>
Array
(
'Name' => 'FolderB'
'Value' => 'Archive/Folder2FolderA/FolderB'
'Attributes' => 64
'Delimiters' => '/'
)
)
And that I am seeking:
Array
(
[0] =>
Array
(
'Name' => 'Archive'
'Value' => 'Archive'
'Attributes' => 32
'Delimiters' => '/'
'SubNode' =>
Array
(
[0] =>
Array
(
'Name' => 'Folder1'
'Value' => 'Archive/Folder1'
'Attributes' => 32
'Delimiters' => '/'
'SubNode' =>
Array
(
[0] =>
Array
(
'Name' => 'FolderA'
'Value' => 'Archive/Folder1/DossierA'
'Attributes' => 64
'Delimiters' => '/'
)
)
)
[1] =>
Array
(
'Name' => 'Folder2'
'Value' => 'Archive/Folder2'
'Attributes' => 32
'Delimiters' => '/'
'SubNode' =>
Array
(
[0] =>
Array
(
'Name' => 'FolderA'
'Value' => 'Archive/Folder2/FolderA'
'Attributes' => 32
'Delimiters' => '/'
'SubNode' =>
Array
(
[0] =>
Array
(
'Name' => 'FolderB'
'Value' => 'Archive/Folder2/FolderA/FolderB'
'Attributes' => 64
'Delimiters' => '/'
)
)
)
)
)
)
)
)
The normally its should be possible ^^