This tag is used mostly regarding associative arrays (but better use tag "associative-array" for that) and sometimes in the mathematic sense of tag "associativity", the associative property of binary operations.
Questions tagged [associative]
435 questions
-1
votes
1 answer
dropdown from MySQL database
Having solved the populating the dropdown from the array, the next phase of my project is pulling data from a database to allow users to put limits on the data they want to see.
Again, I'm having trouble populating the dropdown. This time however,…

Sam McLean
- 71
- 7
-1
votes
1 answer
How do I use for each loops to group information by year from an associative array
Sorry about the bad title.
First off I'm pulling a MySQL date and news articles attached to the date I have the information in an associative array.
My MySQL query is:
select year(news_date) as a year,
month(news_date) as the month,
news_content…

user2877018
- 1
- 1
-1
votes
1 answer
How to store an array as a string php?
I have a javascript that formats an HTML table that takes some parameters to configure it. I also have a reports table in mysql that contains definitions of my reports: a field for the report name, description, sql, footer, permissions, report…

Curious User
- 39
- 1
- 6
-1
votes
1 answer
insert data in associative array based on condition PHP
I have two arrays:
$sizes and $percentages
$sizes looks like this:
"sizes":{"0":{"size_id":5,"it":"50","us":"32"},"1":{"size_id":4,"it":"48","us":"30"}},
and $percentages like this:
"percentages":[{"5":"70"},{"4":"30"}]
I want to insert the data…

Chriz74
- 1,410
- 3
- 23
- 47
-1
votes
2 answers
Next element of array every iteration chat messages display php
I want to display messages in my chatbox but my code displays only first row from database. I hope polish names of variables arent problem. Greets.
Chatbox:
phpmyadmin rows:

bartekh
- 1
- 1
-1
votes
1 answer
Passing an associative array to PHP
I have an associative array in JavaScript that looks something like this:
data = { 1: "DA", 2: "DA", 3: "NE", 4: "DA", 5: "NE", "ime": "Kojo" }
I've converted it using jQuery.param(data) and I got something…

Aleksa Kojadinovic
- 337
- 3
- 14
-1
votes
2 answers
PHP Associative Array Specific Value.
I have been trying to figure this out for a while now. Please any advice would be appreciated. I just need to access the array for ["Item"]. How do I gain access to this?
array(1) {
[0]=>
object(SimpleXMLElement)#16 (2) {
["@attributes"]=>
…

JGregory
- 3
- 1
-1
votes
2 answers
How can we return an associative array which uses php classes with PDO?
public function displayMember()
{
$statement=$this->db->query("SELECT user_name,user_email,user_gender,date_of_join,user_firstname FROM tbl_users");
while($row=$statement->fetch(PDO::FETCH_ASSOC))
This is from a class file.…

Krishnadas PC
- 5,981
- 2
- 53
- 54
-1
votes
2 answers
PDO Prepared Statement Execution - How to get only associative keys?
This should be a simple thing to solve...
I have got these estatements when a user logs in:
$query = $conn->prepare("SELECT * FROM admins WHERE username = :user AND password = :pass");
$query->bindValue(":user", $user);
…

JuanBonnett
- 776
- 3
- 8
- 26
-1
votes
2 answers
Counting occurrences of a word in a string Javascript
Does anyone know a simple way of counting the occurrences of a word in a Javascript String, without a predefined list of words that will be available? Ideally I would like it to output into an associative array (Word, Count).
For example an input…

user1840255
- 287
- 1
- 6
- 15
-2
votes
1 answer
Sorting a PHP associative array
I would like my associative array to have its elements sorted. Currently, my array is like:
Array
(
[1585] => Chicago, Ohio,Dallas, Denver, Detroit, Houston, Las Vegas, So. Calf.
[1586] => Chicago, Ohio, Dallas, Denver, Houston, Las Vegas,…

vims
- 29
- 1
- 1
- 2
-2
votes
1 answer
How to get multidimensional associative array to sub multidimensional associative array in PHP?
I have a multidimensional PHP array, how can I get a multidimensional associative array where the key will be the value of meetingId['0'] and value will be the value of playback['0']?
Array(
[returncode] => Array([0] => SUCCESS)
[message] =>…

MILAN SAHANA
- 76
- 11
-2
votes
3 answers
-2
votes
1 answer
Associative array is not working
The code below is not working Indexed arrays work fine,
Look Out World
"19", "john"=>"18, "alex"=>"17");
asort($age);
//looping an associative…

Sugumar Venkatesan
- 4,019
- 8
- 46
- 77
-2
votes
2 answers
How to echo both the name and the value in an associative arrays
I have the following code to find all the values of an array and echo them...
foreach($_POST as $result) {
echo $result;
}
But I want to be able to find the name of the array item too such as...
foreach($_POST as $result) {
echo "The…

Speedysnail6
- 67
- 1
- 6