associative-array

Perl - find and save in an associative array word and word context

此生再无相见时 提交于 2019-12-30 11:15:16
问题 I have an array like this (it's just a little overview but it has 2000 and more lines like this): @list = ( "affaire,chose,question", "cause,chose,matière", ); I'd like to have this output: %te = ( affaire => "chose", "question", chose => "affaire", "question", "cause", "matière", question => "affaire", "chose", cause => "chose", "matière", matière => "cause", "chose" ); I've created this script but it doesn't work very well and I think is too much complicated.. use Data::Dumper; @list = (

ORA-21700: object does not exist or is marked for delete for Associative Array as input parameter called from ODP.NET

偶尔善良 提交于 2019-12-30 10:24:10
问题 I have this package code on Oracle 12c CREATE OR REPLACE PACKAGE Support_Data_Types AS TYPE ttDate IS TABLE OF DATE END Support_Data_Types; PROCEDURE GetData ( tabDates IN SUPPORT_DATA_TYPES.TTDATE, ) AS BEGIN SELECT count(*) INTO n FROM table(tabDates); END GetData; If I call it from PL/SQL code it works declare dates SUPPORT_DATA_TYPES.TTDATE; begin dates(1) := To_DATE('12/31/2005','MM/DD/YYYY'); dates(2) := To_DATE('03/31/2006','MM/DD/YYYY'); dates(3) := To_DATE('06/30/2006','MM/DD/YYYY');

Converting months between numeric and number using awk

拜拜、爱过 提交于 2019-12-30 07:16:07
问题 In a past paper for an exam I have the question: Months can be represented in different ways, for example as numbers (1, 2, …, 12), or as three- letter month names (Jan, Feb, …, Dec). Suggest how associative arrays in awk can be used to translate from three-letter month names to month numbers, and vice versa, to translate month numbers to three-letter month names. So I thought I would use associative arrays in the format say the input of the month is in $1: number_to_month["Jan"] = 1; print

Get value without knowing key in one-pair-associative-array

≡放荡痞女 提交于 2019-12-30 02:44:11
问题 There is an associative array with only one pair key=>value . I don't know it's key, but I need to get it's value: $array = array('???' => 'value'); $value = // ?? $array[0] doesn't work. How can I get it's value? 回答1: You can also do either of the following functions to get the value since there's only one element in the array. $value = reset( $array); $value = current( $array); $value = end( $array); Also, if you want to use array_keys() , you'd need to do: $keys = array_keys( $array); echo

PL/SQL bulk collect into associative array with sparse key

ぃ、小莉子 提交于 2019-12-30 02:07:04
问题 I want to execute a SQL query inside PL/SQL and populate the results into an associative array, where one of the columns in the SQL becomes the key in the associative array. For example, say I have a table Person with columns PERSON_ID INTEGER PRIMARY KEY PERSON_NAME VARCHAR2(50) ...and values like: PERSON_ID | PERSON_NAME ------------------------ 6 | Alice 15 | Bob 1234 | Carol I want to bulk collect this table into a TABLE OF VARCHAR2(50) INDEX BY INTEGER such that the key 6 in this

php loop through associative arrays

我的未来我决定 提交于 2019-12-28 04:29:05
问题 Editing this code here on Stackoverflow and I'm really near to get the result I need. So I have this code posted down here: $friends = $facebook->api('/me/friends'); if(!empty($friends['data'])){ $size = variable_get('facebook_graph_pic_size_nodes','square'); $protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http'; foreach($friends['data'] as $data){ $fbid = $data['id']; $fbfriendlikes[$fbid]=$facebook->api('/'.$fbid.'/likes'); } The $fbfriendlikes outputs me an

Comment associative array in PHP Documentor

与世无争的帅哥 提交于 2019-12-28 04:13:09
问题 I use several associative arrays in my PHP application and I'm using PHP documentor to comment my sources. I never really did specify comments for the arrays in an array, but now I need to do that and don't know how. $array = array('id' => 'test', 'class' => 'tester', 'options' => array('option1' => 1, 'option2' => 2)) How do I comment this array in the correct way for @var and @param comments? I could do this like this, but I don't know if this is correct: @param string $array['id'] @param

Comment associative array in PHP Documentor

若如初见. 提交于 2019-12-28 04:13:07
问题 I use several associative arrays in my PHP application and I'm using PHP documentor to comment my sources. I never really did specify comments for the arrays in an array, but now I need to do that and don't know how. $array = array('id' => 'test', 'class' => 'tester', 'options' => array('option1' => 1, 'option2' => 2)) How do I comment this array in the correct way for @var and @param comments? I could do this like this, but I don't know if this is correct: @param string $array['id'] @param

PHP - Accessing array element within the same array

与世无争的帅哥 提交于 2019-12-25 18:24:06
问题 Having an array, I want to call a value giving a key within the same array! In my following example, I have tried to call a particular value giving the key 'default' within the same array, but without success! Is it possible to do that in PHP? Here is my array: $inc_folders = array( 'default' => "def_folder", 'file' => $inc_folders['default'] . "/textfile.txt" ); calling the value in $inc_folders['file'] , I would want the result be the following: "def_folder/textfile.txt" ; but I obtain an

Using Laravel's pluck method without an associative array

泄露秘密 提交于 2019-12-25 08:16:12
问题 Let's say I've got an Article s collection, and I want to fetch the popular articles. So first, I make a scopePopular() method in the Article method. Very simple. Now I want to fetch their id s, so I'll do this: Article::popular->pluck('id'); The result will be an associative array: [ 0 => 1, 1 => 34, 2 => 17 ... ]; I want to get a normal array, without the keys, Like: [1, 34, 17] I know I can just do something like this: array_values(Article::popular->pluck('id')); But I believe Laravel has