php,oop,associative-array
First we have a property which is the array: private static $_errors = array(); An error can be added by sending it to a function, which will add it to the array: public function addError($error){ self::$_errors[] = $error; } In any function, I can easily add an error as a...

java,json,data-structures,associative-array
I need to store key-value pairs inside key-value pairs and so on as required by the data. I tried to achieve this using Hash-Map in java but it didn't work as I expected it to. Since, my data has multiple name->value pairs, but the Hash-Map keeps overwriting the name key's...

php,arrays,string,associative-array
I have an associate array. I want to remove duplicate values if the value has appear first. Let's say if DC-30 has appear first, remove all DC-30 in the associate array. If HSD-M has appeared already, remove all HSD-M in the associate array. I'm doing all of this in while($row...

php,arrays,session,associative-array
This question already has an answer here: Notice: Unknown: Skipping numeric key 1 in Unknown on line 0 1 answer example: $_SESSION['10'] = 'testing'; echo $_SESSION['10']; The above will not print out anything...i found out(after a long time of frustration) that you cannot use a string numeral as a...

r,associative-array
I have a data frame where one column is a factor. I want to map that column into integers. For instance, in the example below, I want to map healthy to the value 2, sick to the value 1, and dead to the value 0. In this example the order...

php,mysql,select,sql-injection,associative-array
I am trying to set up PHP queries for MySQL in a way to prevent SQL injection (standard website). I had a couple of INSERT queries where changing this worked well but on the following SELECT I keep getting an error since the update and it looks like the while...

php,string,associative-array
I have a PHP associative array that I am trying to extract data from: array(18) { ["body"]=> string(34) "Hey! Let me know if you got this"} The above array is stored in a variable called $firstChildData, and when I try to run the following line, I get the result below...

php,multidimensional-array,associative-array
I have an associative array that is essentially static dummy data for a mock-up that is standing in for a database. I am trying to replicate what GROUPBY YEAR AND TitleText would do in MySQL and I can make it work on one field - either TitleText or YEAR using...

c++,c++11,associative-array,c++-standard-library
I was looking for the most efficient and expressive way to remove the last element from a std::map. I tried: #include <map> int main() { std::map<int, int> m; m.insert(std::make_pair(1,1)); m.erase(m.crbegin()); return 0; } The code does not compile, since std::map::erase can take only std::map::const_iterator. Moreover, prior to C++11 it could...

php,arrays,associative-array
what i need to need i need to fetch some key values and store in another array. api data Array ( [0] => Array ( [id] => 180462 [des] => India International Bearing Expo New Delhi is a 3 day event being held from 5th June to the 7th June...

php,arrays,associative-array
I have this array: 'tab1' => '', 'tab2' => '', 'tab3' => 'active' I want to do array_flip to swap the keys with the values, but the entries with an empty value are not kept. How do I let PHP assign integer keys for me (like with an indexed array)?...

php,arrays,multidimensional-array,associative-array
I have stored many arrays in a single associative array and assigned key values simple number counting. How can I extract one of those array from the associative array? my array: $arr = array( 1 => array("ask","bat","cod","dig","egg","fur","gap","hay","ice","jar","kin","lee"), 2 => array("add","big","cap","day","eye","fat","gel","hop","ink","jog","key","law"), 3 => array("axe","bin","cel","don","eat","fig","gig","hut","ion","jin","kid","lip") ); I want to store the array...

php,mysql,codeigniter,associative-array
using CI I'm trying to set up query with three parameters: user_id, content_type and content_id in which content_id is array of IDs. So I need to get up with something like this: SELECT name FROM content WHERE user_id = 2 AND content_type = file AND (content_id = 4 OR content_id...

javascript,multidimensional-array,while-loop,associative-array
i have a problem width this simple code... I created an associative array width a while cycle that should be constituted of four elements... the problem is that it works only width the first two elements : matrice[1][1] and matrice[1][2]... not width matrice[2][1] and matrice[2][2] thanks in advice! <html> <head>...

delphi,tree,associative-array,tdictionary,delphi-xe8
I just wrote a very simple class to test the TDictionary<> Class in Delphi XE8. When i try to show the records that i added, it brings me an Access Violation error, i don't understand why? Here is my class unit Unit3; interface uses Classes, System.SysUtils, System.Types, REST.Types, System.JSON, Data.Bind.Components,...

php,arrays,image,associative-array,imageurl
I'm using one CMS written in PHP. I'm making use of it's built-in functions to do the operations. At one place I want to get the path of an image for it following is the code which is working fine and returning the image. $sUserProfileImage = Phpfox::getLib('image.helper')->display(array_merge(array('user' => Phpfox::getService('user')->getUserFields(true)), array...

php,multidimensional-array,associative-array
I've got a very large JSON file that I've converted into an array. The code you see below is the result of var_dump($array['talents']) (for those wondering, yes, this is me attempting to use Blizzard Entertainment's API) Maybe I just missed that day at PHP school, but I just can't seem...

php,arrays,serialization,associative-array,key-value
I've an array titled $aFilter. Upon serializing it few numbers are getting inserted into it. I'm not understanding why did it happen? Why did it insert the numbers and in which pattern? Can someone please guide me what actually this serialize() does and generates such kind of output in an...

php,arrays,associative-array
Quick and short question. The code below is just the way I want it to be. For some reason, however, it doesn't work. No errors are shown (error_reporting is -1) and nothing happens. <?php $data_clean_type = 'numeric'; $data_clean_filter = array('alpha' => '/^[a-zA-Z]*$/', 'numeric' => '/^[0-9]*$/', 'alphanumeric' => '/^[a-zA-Z0-9]*$/'); if(in_array($data_clean_type, $data_clean_filter))...

php,arrays,associative-array
I have a query that returns an associative array. In that array are fields I must remove before output. I've tried array_diff and unset, but not having any luck. The beginning array: Array ( [id] => 13461 [ln] => 605717 [ptyp] => COND [lag] => 86484 [st] => S [lp]...

php,arrays,associative-array
I have the array: array(2=>'0',3=>'1',5=>'3',4=>'4',7=>'2') Note: Nothing seems to be in order. So leave the plan to find a numeric order. How can I fixed the i'th element of this associative array? For example when i is 4 the value should be 4, when i is 1 the value should...

php,jquery,ajax,json,associative-array
my query gives result query_string and query_string_id i want that result to provide data for ajax and send it to php but i dont know how to send associative array through ajax pls help me to build my code function querySuccessEnds(tx,results) { var len = results.rows.length; console.log("DEMO table: " +...

oracle,plsql,associative-array
Im trying to delete a set of tables and afterwards I want to recreate them using as select from. For couriousity I wanted to do this with an associative array. Unfortunately something is messed up, several errors appear and I can't find the reasons. This is the code: DECLARE TYPE...

linux,bash,shell,unix,associative-array
I am currently trying to loop through an associative array. This array contains values with the same key. However, when I tried to loop through it, I only get one set of results. How can I loop through all the values containing the same key? #!/bin/bash/ declare -A details=( [dog]="golden...

php,arrays,substring,associative-array
This is my array (input): $value = array("jan01" => "01", "feb02" => "02", "mar03" => "03", "apr04" => "04"); I am using this code to get the array keys: implode(" ", array_map("ucwords", array_keys($value))); Now my problem is I want to get all keys by triming the last two characters of...

php,foreach,associative-array
This question already has an answer here: Two arrays in foreach loop 13 answers I've got 2 arrays with the same $key. So arrays are: $users and $new. $users['user_id']=['user_name']; $new['user_id']=['user_color']; How can I foreach them that I could get something like this: foreach (bla bla bla){ echo '<option color="'.$new['user_color'].'"...

php,for-loop,associative-array
I want to insert two values in an associative array one for the key and second for the value and as i print that array it should contain all a-k as keys and 0-10 as their corresponding values. <?php $z=array("a","b","c","d","e","f","g","h","i","j","k"); $countsub1 = array(); for($i=0;$i<=10;$i++) { $countsub1 = array("$z[$i]","$i"); } print_r($countsub1);...

dictionary,awk,associative-array
I figured out the following code to find duplicate UIDs in a passwd file, but it doesn't include the first instance (the one that was later duplicated), I ultimately wanted to have a dictionary with UID = [ USER1, USER2 ] but I am not sure how to get it...

php,arrays,multidimensional-array,key,associative-array
This question already has an answer here: Is there a function to extract a 'column' from an array in PHP? 13 answers Let's say that I have an array like this: $people = array( array( 'name' => 'Bob', 'job' => 'Carpenter' ), array( 'name' => 'George', 'job' => 'Programmer'...

php,arrays,associative-array
QUESTION: In the second (following) code snippet, in the inner foreach loop (that is the foreach loop nested in another foreach loop), the $value corresponds to an element of the $studentCoursesStudied, and NOT the $studentCoursesStudied array itself, right? The correct way to access the value of an element of the...

linux,bash,shell,awk,associative-array
Originally, the file has its contents like this: 1.2.3.4: 1,3,4 1.2.3.5: 9,8,7,6 1.2.3.4: 4,5,6 1.2.3.6: 1,1,1 after I have tried sorting it incorrectly I have this: 1.2.3.4: 1,3,4,4,5,6, 1.2.3.5: 9,8,7,6, 1.2.3.6: 1,1,1, I want to sort it into the following format: 1.2.3.4: 1,3,4,5,6 1.2.3.5: 6,7,8,9 1.2.3.6: 1 but how do...

java,php,associative-array
I'm from a PHP background, and I'm trying to create a multidimentional array with a difficulty in understanding the Java way of doing things. I thought this could be achieved using JSON and the GSON library, but I'm failing to understand how this is done having followed several tutorials online....

php,arrays,json,multidimensional-array,associative-array
I'm retrieving bibliographic data via an API (zotero.org), and it is similar to the sample at the bottom (just way more convoluted - sample is typed). I want to retrieve one or more records and display certain values on the page. For example, I would like to loop through each...

php,mysqli,associative-array
I am having some issues with the below, wanting to add the query result "id" as the key to the value "concat" -- Do I need a foreach for this? What is the best way? $concatCol = mysqli_query( $connS, "SELECT id, ShipmentNumber, InvoiceNumber, BillofLading from testTable"); $data =array(); while ($row...

php,arrays,multidimensional-array,associative-array,error-reporting
I wrote a program to define an associative array titled $aFilter and tried to print it but I'm not able to. I tried two ways to achieve this but couldn't succeed. Following are the two ways I tried. Way 1: <!DOCTYPE html> <html> <body> <?php $aFilter = Array ( ['pages']...

php,multidimensional-array,associative-array
I am attempting to print out a table of the PHP multi-dimensional associative arrays. There are arrays for the class, assignments, students, scores. I am familiar with MySQL queries, but I am not sure how to print out the table from a PHP multi-dimensional associative arrays. My thought process to...