21 Solved Topics

Remove Filter
Member Avatar for
Member Avatar for rsleventhal

At times, I have need to push all submitted form array values into $_SESSION. To do this, I've written a small function: function addPostToSession() { foreach ($_POST as $key=>$value ){ $_SESSION[$key]=stripslashes(strval($value)); } } This works well, as long as $_POST is one dimensional, but in a form with checkboxes, $_POST …

Member Avatar for cereal
0
394
Member Avatar for diafol

Hi all. Have been racking my brains about how to go about creating a multidimensional array dynamically from an array of keys. Something like... $keys = array('key1', 'key2', 'key3'); $value = 'some value'; // $md = ...???!!!... I need the $md multidimensional array to have the keys thus... $md['key1']['key2']['key3'] = …

Member Avatar for Webville312
0
9K
Member Avatar for theashman88

So I'm basically trying to recreate the simulation of two dice being rolled, and I need to count the frequency in a two dimensional rectangular array, then display the array. I'm so lost I wrote some code but it didn't work, can anyone help. This is the assignment I'm not …

Member Avatar for cgeier
0
434
Member Avatar for CJMW

So, Im making a game in c# using Xna. I have a function that will read a text file and display a map on screen, using numbers in the file as texture references. The file is a integer multidimensional array. I have another file which is used to set collision …

Member Avatar for CJMW
0
383
Member Avatar for PerplexedB

Please consider the following class : <?php class p0110dbinsertbuilder { public $table=""; private $fields ; public function add($Field,$Value){ $this->fields = array($Field,$Value); } public function insertstring(){ $count = count($this->fields,0); $c = "INSERT INTO " . $this->table . "("; for ($i=0;$i<$count;$i++){ $c .= $this->fields[$i][0]; if ($i <> $count-1){ $c .= ","; } …

Member Avatar for PerplexedB
0
220
Member Avatar for cussel

>Hi guys,..i've two arrray data1 and data2 then i do intersect to get same value between data1 and data2, and >use count to get total same value,..how to ARSORT count result from intersect array multidimensional? <?php $data1 = array( array( '7' => 'chelsea everton', '8' => 'everton villa', '9' => …

Member Avatar for broj1
0
330
Member Avatar for cussel

>hi guys, how to get first and last (key and value) array multidimesional below? $data1 = array( array( '0'=>array( '7'=>'chelsea', '8'=>'everton', '9'=>'villa', '10'=>'liverpool' ), array( '23'=>'milan', '24'=>'inter', '25'=>'juventus', ), ), '1'=>array( array( '53'=>'madrid', '54'=>'barcelona', '55'=>'altetico', '56'=>'everton', ), array( '243'=>'milan', '244'=>'inter', '245'=>'juventus', ), ), '2'=>array( array( '523'=>'madrid', '524'=>'barcelona', '525'=>'altetico', '526'=>'everton', ), …

Member Avatar for diafol
0
383
Member Avatar for Mike_H

I have the following code in my **PHP** program: $query = "SELECT * FROM board_members"; $result = mysql_query($query) or die(mysql_error()); $data = array(); // create a variable to hold the information while (($row = mysql_fetch_array($result, MYSQL_ASSOC)) !== false){ $data[] = $row; // add the row in to the results (data) …

Member Avatar for Mike_H
0
251
Member Avatar for NuGG

I have an array of file names which gets split into 3's using array_chunk, then using array_push "X" is added to each array chunk. I now want to to reassemble the array chunks into one "2D" array. I have been playing around with array_merge, but I can only get the …

Member Avatar for NuGG
0
487
Member Avatar for rhguh

I am working on a project that requires a CSV file to be read into a multidimensional array. I loop through the array, and set multidimensionalarray[x][n] to the corresponding data in the CSV file, but I keep getting IndexError: list index out of range. I can't figure out why, and …

Member Avatar for rhguh
0
290
Member Avatar for nyuszi

Hi i need a little help. i want to read a multi array from a file but code blocks said a lots of error and i dont know whats the problem. can u help me? [ICODE]#include <iostream> #include <cstdlib> #include <math.h> #include <fstream> #include <sstream> using namespace std; int maxn=100; …

Member Avatar for nyuszi
0
256
Member Avatar for aru211285

Dear All, I have created a multi dimensional array and stored elements in that through while loop like $human = array(); and at every iteration the while loop will add elements like $human["IPI"]["Description"][] = $row; $human["IPI"]["link"][]= $link; but when i wanted to print this array contents in a table format …

Member Avatar for diafol
0
503
Member Avatar for atfOnly

Hello people :) i'm trying to insert query result into 2 dimensional array i have tried the following way.. [CODE] $query=mysql_query("..."); while($row=mysql_fetch_array($query)){ for($i=0;$i<=$index;$i++){ if(isset($myarray[$i]['array1'])|| isset($myarray[$i]['array2'])){ array_unshift($myarray[$i]['array1'],$row['study_period']); array_unshift($myarray[$i]['array2'],$row['test']); }//endif }//endfor }//endwhile [/CODE] But, it failed i also tried.. [CODE] $query=mysql_query("..."); while($row=mysql_fetch_array($query)){ $myarray=array( array("array1"=>$row['study_period'],"array2"=>$row['test']) ); }//endwhile [/CODE] it failed too since it …

Member Avatar for atfOnly
0
258
Member Avatar for atfOnly

Hello all! :) Do you have any link on some complete reference on multidimensional array in php?? Please tell me.. thanks a lot.

Member Avatar for atfOnly
0
169
Member Avatar for Splam Bub

Hello DaniWeb! I'm trying to return an array of strings from a function but I'm not sure how to do so. I've done the prerequisite Googling and have found people on this discussion board recommending to return char** which, it is said, can then be converted back into 2d array …

Member Avatar for Splam Bub
0
152
Member Avatar for ceatkin2

I am trying to define a 2D array of 1000 by 1000 ints and then test which transversal method is faster (row major or column major). I have this written [CODE] #include <stdio.h> #include <time.h> int main() { clock_t start, end; double elapsed; start=clock(); int array[1000][1000]; int row, col; for(row=0; …

Member Avatar for ceatkin2
0
164
Member Avatar for TinhornAdeniyi

I cant figure out what is wrong with this code These are the instructions [ATTACH]17304[/ATTACH] [ATTACH]17305[/ATTACH] [ATTACH]17306[/ATTACH] and this is my code [CODE]#include<iostream> #include<fstream> #include<iomanip> using namespace std; void Get_Info(string[],int[][3]); void Get_Average(int[][3]); void Prt_GradeBook(string[],int[][3],int[]); int MakeUps(int[][3]); int Grades[5][3],average[5]; string Students[5]; int main() { Get_Info(Students,Grades); Get_Average(Grades); Prt_GradeBook(Students,Grades,average); cout<<"There are"<<MakeUps(Grades)<<"Makeup(s) to arrange. …

Member Avatar for VernonDozier
0
187
Member Avatar for newprimitive

Hello, In OOP PHP, i got 2 classes: Database and News. In News class i call DB function and get result (multidimensional 2D array). Now i have to display that array in index.php. I call News class (lets say get_news() function) from index.php but cant retrieve data and always get …

Member Avatar for Stefano Mtangoo
0
153
Member Avatar for Griff0527

I am trying to create a code that receives up to 50 integers from the keyboard, sorts the array from largest to smallest, then counts the instances of each number and displays the number inputted and the count of the number of instances. For example, if the number 11 was …

Member Avatar for NathanOliver
0
1K
Member Avatar for Sandhya212

Hi, I have code as follows wherein I pass a 2D array to a function and want to receive this array with its contents tripled. [CODE]#include <iostream> #include <cstdio> using namespace std; int** test2 (int arr2[][4],int mul){ for (int i=0;i<2;i++){ for(int j=0;j<4;j++){ arr2[i][j]=arr2[i][j]*mul; } } return arr2;//sending back the address …

Member Avatar for Sandhya212
0
456
Member Avatar for Sheltac

Hi guys! I'm pretty new to C++. I am currently on freshman year at college, and have a programming problem (not homework, it's actually a side project of mine) that consists on implementing some algebra-related functions on C++. I'll go straight to the point: [code] int switchlines(int i, int j, …

Member Avatar for Sheltac
0
157

The End.