Arrange Query Table Into Multidimensional Array
I have 3 tables: a list of articles, a list of authors, and a table joining the two via the article and author IDs. The join table looks like this:
art_id auth_id ord
1 1 1
2 1 1
2 4 2
So author 1 contributed to both articles 1 and 2. The "ord" field is the order in which the author appears in the citation. Code:
View Complete Forum Thread with Replies
Related Forum Messages:
Multidimensional Array In To A MySQL Table
Trying to load an multidimensional array into a MySQL table with columns as follows, level1,level2,level3,illust,item,description,partN o,qua,price,remarks,weight ,size,mass the array first line is $input[0][level1]Engine the array secondline is $input[0][level2]Cylinder Head etc.. A 'foreach' inside a 'foreach' echo of the array gives the following, which is correct. 0, level1, Engine 0, level2, Cylinder Head 0, level3, 0, illust, 001.pdf 0, item, 1 0, description, Casting 0, partNo, 238356 0, qua, 1 0, price, 1,245.00 0, remarks, This is for the Z350 series 0, weight, 5 0, size, 5x5x5 0, mass, 37 1, level1, Engine 1, level2, Cylinder Head 1, level3, 1, illust, 001.pdf 1, item, 2 1, description, Valve, inlet 1, partNo, 452790 1, qua, 4 1, price, 5.46 1, remarks, This is for the Z350 series 1, weight, 5 1, size, 5x5x5 1, mass, 37 2, level1, Engine 2, level2, Cylinder Head 2, level3, 2, illust, 001.pdf 2, item, 3 2, description, Valve, exhaust 2, partNo, 345436 2, qua, 4 2, price, 5.99 2, remarks, This is for the Z350 series 2, weight, 5 2, size, 5x5x5 2, mass, 37
View Replies !
Can I Put A Mysql Query Result Directly Into A Multidimensional Array?
I have two joined tables: Departments - which contains the department description and a key Positions - which contains position data What I'm attempting to achieve is to display the department title in one table cell and then list all the positions associated with that department in the cell under neither the title. I need to generate a table two column table with as many rows as required, depending on the number of departments, which is dynamic. Do this I'm trying to turn the result of my SQL query into multidimensional array e.g. dept = VioP positions = "designer", "engineer" etc, which I can do then use to generate the table. I've done a search on the forum and looked around the manual and I'm stumped on how to achieve this, a point in the right direction would be greatly appreciated. The query I'm using is below. PHP Code:
View Replies !
Arrange Table
I am making a "standings" page for a league. I made everything so that it calculates how many points the team has, and now I want it to arrange each row in descending order according to how many points a team has. To see an example of what just goto download.com and search anything and click for it to list it by downloads or something.
View Replies !
Last Record Of Table Not Showing Up (3x Array Query)
I ran into some touble with my already pretty confusing project. I finally managed to figure out how I can link 3 tables together and show info from all per cell of a table.. this required a couple of while loops and it works like a charm except I am missing the last record Code:
View Replies !
Multidimensional Array Syntaxt For Preg_split Array Using Submitted Textarea
I have two textarea's called textarea1 and textarea2. What i did was use preg_split to split the textarea into seperate rows that i could use for analysis like so $array = preg_split("/[ ]?[ ]/", $_POST['textarea2'], -1,PREG_SPLIT_NO_EMPTY); $array2 = preg_split("/[ ]?[ ]/", $_POST['textarea1'], -1, PREG_SPLIT_NO_EMPTY); then i used a function created for me by a nice guy on here called get_ending($filepath) which basically stripped off of each peice of text the "http://www" from every URL i put into the textareas finishing off i wanted to create an array that would input an expression such as: echo "<a href='$array[1]' target='_blank'><img src='$array2[1]' border='0'>"; into a text area on the next page. ALL of this works, except that i dont know how to properly loop throught he array so it'll properly insert the text into the textarea on the next page. For now, all it does is place the array information in the page, rather statically, i would like to run some kind of if then statement that says "while $array has some kind of text in it, keep running this operation of echoing the following expression adding 1 to the end of the array number" I hope that makes sense Any ideas? Code:
View Replies !
Accessing Array Values Inside A Multidimensional Array
I need to access a value which is inside in a multidimensional array... Suppose there is a form and where I takes all the form values inside an array named access..and I post the values into a different array. $registrationArray = $_POST['access']; Now I need to loop through this registration array and get values printed to the new variables... Suppose this is the array $access = array (fname,lname,date,year,month) How do I print the date,year,month values into different variable by looping through registration array..
View Replies !
Passing Array Of Multidimensional Array To Function
How do I pass a part of a multidimensional array to a function. I have the following (in pseudo): $arrays[m][n]; // filled with values $chosen = 3; function doSomething($array) { // do something with 1D array } This fails: doSomething($arrays[$chosen]); Can someone explain to me why? And how to do this right?
View Replies !
Multidimensional Array: See If 1st Key Is Available
I've got an multidimensional array $ret = $country_code[$countryCode][$langCode]; Now I want to see if $countryCode is even in that array, because if it's not, it doesn't make many sense to look further for $langCode. Eg. $country_code = array('BE' => array ('en' => 'Belgium', 'nl' => 'België'), 'NL' => array ('en' => 'Netherlands', 'nl' => 'Nederland'), ); Searching for 'BE' would make sense, but 'LP' wouldn't. I already tried: $arr = array($country_code['LP']); if (sizeof($arr) == 0) print "LP not found!" But that doesn't seem to work :-s.
View Replies !
Multidimensional Associated Array
I try to construct an array such that each element of it is another array returned by the fetch_array_function: for ( $i = 1; $i<=$n; $i++ ) { $ar[$i] = mysql_fetch_array( $result ); print "$ar[$i][fieldname] "; It prints "Array[fieldname]". If I replace $ar[$i] by $ar everything works fine! Could you pleas...
View Replies !
2 Multidimensional Array
I have a multidimensional matrix: C1 C2 C3 C4 R1[] [] [] [] R2[] [] [] [] R3[] [] [] [] R4[] [] [] [] R5[] [] [] [] R6[] [] [] [] R7[] [] [] [] R8[] [] [] [] 1. Is it possible to search in a specific column? eg: only search for a value in in C2 and get the rownumber as result? 2. Copy one or more rows and put them in between other rows? eg: move row 5 and 6 between row 1 and row 2. C1 C2 C3 C4 R1[] [] [] [] R5[] [] [] [] R6[] [] [] [] R2[] [] [] [] R3[] [] [] [] R4[] [] [] [] R7[] [] [] [] R8[] [] [] []
View Replies !
Multidimensional Array
I am trying to build a random card generator and once a card is chosen it gets taken out of the array. this is what i have so far which is far away from where I need to be. $suites = array("Spade","Clubs","Diamonds","Hearts"); $numbers= array(2,3,4,5,6,7,8,9,10,"Jack","Queen","King","Ace");
View Replies !
How To Reference An Array In Multidimensional Array?
How do I reference an array within an array? $mapped_array = array_map(null, $data_array, $counter_array); // okay, so now I have an array of 2 arrays - but how do I reference each array? // the next two lines fail to give an accurate count echo "Starting with ".count($mapped_array[0])." elements in data_array<br>"; echo "Starting with ".count($mapped_array[1])." elements in counter_array<br><br>"; // now I want to start at the bottom and look for an IP in each line of data_array // which I assume is mapped_array[0] for ( $i=count($mapped_array[0]); $i > 0; $i-- ) { $data_line = $mapped_array[0][$i]; $data = explode("|", $data_line); if( in_array($ip, $data) ) { // if there's a match, element[$i] of both arrays needs to be spliced out array_splice($mapped_array,$i,1); } } // again, these next two lines fail to return an accurate count echo "Ending with ".count($mapped_array[0])." elements in data_array<br>"; echo "Ending with ".count($mapped_array[1])." elements in counter_array<br><br>"; Is there something about array_map that prevents me from referencing the arrays within the array?
View Replies !
Problems Using Multidimensional Array
I am trying to understand multidimensional arrays within PHP, and am trying to do the following: $x[1][1]="test"; $x[1][2]="test2"; $x[2][1]="test3"; $x[2][2]="test4"; print ("$x[1][1] $x[1][2] $x[2][1] $x[2][2]"); but instead of getting the result: test test2 test3 test4 I am getting: Array[1] Array[2] Array[1] Array[2] Can someone please explain why this is happening.
View Replies !
Break Down Multidimensional Array
I have a multidimensional array and was wondering how it can be broken down... Array ( [0] => Array ( [0] => Array ( [0] => 1 [intsch_id] => 1 ) [1] => Array ( [0] => 2 [intsch_id] => 2 ) ) ) And I want to break it down to Array ( [0] => 1 [intsch_id] => 1, [1] => 2 [intsch_id] => 2) And this is in a dynamic query, so the results won't always be this simple. It will have the same structure as the above multidimensional array.
View Replies !
Create A Multidimensional Array From XML Doc
Currently I have the following XML document: <Programs> <Program> <ProductTypeName>30 Yr Fixed</ProductTypeName> <Rate>6.250</Rate> <APR>6.274</APR> <InvestorName>Helos</InvestorName> <Payment>2832.298</Payment> </Program> <Program> <ProductTypeName>30 Yr Fixed</ProductTypeName> <Rate>9.250</Rate> <APR>9.293</APR> <InvestorName>Avalon</InvestorName> <Payment>3784.306</Payment> </Program> <Program> <ProductTypeName>5/1 Arm</ProductTypeName> <Rate>6.375</Rate> <APR>6.399</APR> <InvestorName>Carl1</InvestorName> <Payment>2869.802</Payment> </Program> </Programs> I load it up in a domdocument and iterate through it with the following: $returns = array(); for($i = 0; $i < $xmlproducttype->length; $i++) { $returns[$i]['ProductTypeName'] = $xmlproducttype->item($i)->nodeValue; $returns[$i]['InvestorName'] = $xmlinvestorname->item($i)->nodeValue; $returns[$i]['Rate'] = $xmlrate->item($i)->nodeValue; $returns[$i]['APR'] = $xmlapr->item($i)->nodeValue; $returns[$i]['Payment'] = $xmlpayment->item($i)->nodeValue; } Giving me the following style array:
View Replies !
Passing Multidimensional Array Thru The URL
I have an issue with an array that I would to pass to a second php script; please note that I cannot use session. I have been looking at the functions : rawurlencode / rawurldecode urlencode / urldecode but it does not seems to work for my variable here is an example of variable: <? $x=0; $data[$x][title]="My title"; $data[$x][label]=array("label1","label2","label3"); $data[$x][data]=array(100,150,145); ?> How can I pass this variable thru an URL?
View Replies !
How To Return A 'sub-array' Of A Multidimensional One
I have a multi-dimensional associative array, and I'm interested in searching the array for a given key, and returning the 'sub-array' or value associated with this key. for example: Code: $array = array( 'A'=>1, 'B'=>2, 'C'=>ARRAY( 'A2' => 'FRUIT', 'B2' => 'VEGGIE', 'C2' => ARRAY( 'MEAT1' => 'BEEF', 'MEAT2' => 'CHICKEN' ) ) ); I want to retrieve the array under the key 'C2'. I have tried to 'search' the array so that its internal pointer is pointing at this element, then using 'current', but that doens't work: Code: array_key_exists( 'C2', $array ); var_dump( current( $array ) ); I've also tried a small variation of the above in order to get the reference to C2 rather than a deep copy: Code: array_key_exists( 'C2', $array ); var_dump( $array[key($array)] ); I would actually prefer to get a reference into the array rather than a copy.. I guess I'm really stuck on the 'search' part of the mutlidimensional array.. Surely there's a better way (built-in function) than iterating every element and comparing the key?
View Replies !
Single Array To Multidimensional
I have a string, comma separated, with links and their respective URLs in it. Example: Google,http://www.google.com,Yahoo!,http://www.yahoo.com,WikiPedia,http://www.wikipedia.org etc, etc. i make an array of this with explode( ',', $string ); now what i wonder is how can i turn this array into something like this: $array[0]['name'] = Google $array[0]['url'] = http://www.google.com $array[1]['name'] = Yahoo! $array[1]['url'] = http://www.yahoo.com $array[2]['name'] = WikiPedia $array[2]['url'] = http://www.wikipedia.org I hope/think this is all clear ...
View Replies !
Define The Multidimensional Array
I won't post my exact code since the project I'm working on is HUGE and I'd have to explain it all anyways, but I'll provide examples. Basically, I'm using OOP PHP to build this project... and at one point I have the constructor of 'Class1', calling another method of the same class. In that method, I want to add to a multidimensional array defined in the class itself... in the first position I want to store a string, in the next position, I want to store an instance of another class. Now, the problem I'm having is that when I try and define the multidimensional array, it takes FOREVER!!!! Literally 25 seconds! All I'm doing is this: PHP Code:
View Replies !
Multidimensional Array Loop
I am trying to loop through a multidimensional array shopping cart stored in a session. I can loop through it ok but the problem is that when the page displays I have two each of the items in the cart. I am looping through with a double foreach. If I do print "$key: $value"; inside of the second foreach I get the correct display of the items in my cart but then the actual display of the items gives me two of each. Code:
View Replies !
Checkboxes In A Multidimensional Array
I found this nice code online that does exactly what I want it do to: Emails a form that includes the posted values. I can get the text boxes, text areas, and radio buttons to send; however I cannot for the life of me figure out how to get checkboxes to send. It will only send the last-checked value. I have searched the internet and seen that this is a common problem, but I have not found anything similar to the code that I am using. Code:
View Replies !
Sorting A Multidimensional Array
I Have an array set as so: $temparr[$i]['score'] = 3.4 $temparr[$i]['id'] = 1 $temparr[$i]['title'] = 'title' $i loops the array populating it, but when I output the array, i would like to sort it by the 'score' value asc or desc, depending on what i want to show... what is the easiest way of achieving this?
View Replies !
Change Into Multidimensional Array
I have an array that looks like this: Array ( [0] => Array( [fieldID] => 001 [description] => Hi all!) [1] => Array ( [fieldID] => 002 [description] => It’s me again! ) ) And I want to change it into array that would look like this: Array ( 001 => Hi all! 002 => It’s me again! ) Is it possible to do it at all?
View Replies !
Deleting Multidimensional Array
if i have a multi dimentional array, eg: $arr[x][y] = ''; and i want to delete the enrite thing, does unset($arr); rowk, or so i have to delet the second arrays, or how do i do it???
View Replies !
Jump Out Of A Multidimensional Array?
trying to get out of an array dynamically. $transport = array('foot', 'bike', 'car', array('test1', 'test2')); i'm in test2( $transport[3][1] ), how do I go into $transport[3]? Is there a function capable of doing this?
View Replies !
Adding To Multidimensional Array
I'm realtively new to PHP and I'm trying to get my head around a particular issue. I've got an array that looks like this: $field_array = array ( array (field=>"dist_Company", type=>"text"), array (field=>"dist_Active", type=>"select", options=>array(array(oname=>"yes", oval=>"1"), array(oname=>"no", oval=>"0"))), array (field=>"dist_CompanyID", type=>"select"), array (field=>"dist_Shipping", type=>"text") ); What I'm trying to figure out is how to add to this array after it's been defined. In this case I'm trying to add the "options" subarray to dist_CompanyID element so that it has options similar to those predefined in the dist_Active element. I can do it if I specify the index like this: $field_array[2]['options'][] = array(oname=>"one", oval=>"1"); $field_array[2]['options'][] = array(oname=>"two", oval=>"2"); $field_array[2]['options'][] = array(oname=>"three", oval=>"3"); Is there some elegant way to find the index number for the element containing field=>"dist_CompanyID"?
View Replies !
Multidimensional Array Sorting
I'm having some trouble sorting a multidimensional array I have created. The use of this sorting is to set up "standings", sorted by WINS descending, LOSSES ascending, and TIES descending. The array looks as such: Code:
View Replies !
How To Create Multidimensional Array?
I have a table that looks like this: ID --> Product --> Color --> Size 1 --> Shirt --> Brown --> S 2 --> Shirt --> Brown --> L 3 --> Shirt --> Brown --> XXL 4 --> Shirt --> Black --> M 5 --> Shirt --> Black --> XS 6 --> Shirt --> Red --> XL I'm trying to create an array that looks like this: Array ( "Brown" => array("S", "L", "XXL"), "Black" => array("M", "XS"), "Red" => array("XL")) The following gives me two separate arrays, one for colors, and one for sizes: Code:
View Replies !
Unique-ing A Multidimensional Array
I am storing a 3-dimensional array in $_SESSION. The important data has this form: $_SESSION["items"][item_type][item_subtype]. I need to make sure there are no duplicates, where duplicate means the item type and subtype match. I have looked at the comments on php.net for array_unique, and there are multiple posts that claim to provide code for unique-ing a multidimensional array, but I could not get any of them to work. I am wondering if it has something to do with the fact that I'm using $_SESSION.(?). What I want to do (pseudocode) is: array_unique($_SESSION["items"]).
View Replies !
Building Multidimensional Array
In my database I have a couple of fields and I'm trying to create multidimensional arrays out of them. For example, in my db, I have: Colors | Price red,blue,yellow | 50,45,32 yellow,green,purple | 12,47,82 gold | 39 I'd like to build arrays that looks like this: array('red' =>཮', 'blue' => ཀྵ', 'yellow' => ཛྷ') array('yellow' =>཈', 'green' =>ཫ', =>', 'purple'=>ྎ') array('gold' => ལ') Is there a way to do this? I've looked at the array functions in the php manual, but I still don't understand how I can build these from queries to my db.
View Replies !
Multidimensional Array Confusion
If I print_r($_POST) the values submitted by my form, I'll get this: PHP Code: Array ( [Name0] => Doe [Age0] => Array ( [0] => 23 [1] => 28 [2] => 32 [3] => 11 [4] => 9) [Name1] => Smith [Age1] => Array ( [0] => 7 [1] => 8 [2] => 9 ) [Name2] => Jones [Age2] => Array ( [0] => 54 [1] => 42 ) [submit] => Submit ) I'm trying to figure out how to match up the Name/Age arrays so that when I submit it, I'll be able to store the information in my database like this: id Name Age 1 Doe 23,28,32,11,9 2 Smith 7,8,9 3 Jones 54, 42 Is there a way to do this?
View Replies !
Usort Multidimensional Array
I would like to sort the following array by the "make" AND the "model"... it currently sorts by "make" just fine. PHP Code: //Function function sortColumn($a, $b) { return strcmp($a["make"], $b["make"]); } //Array $cars = array( array('make' => 'Ford', 'model' => 'F250'), array('make' => 'Honda', 'model' => 'Civic'), array('make' => 'Honda', 'model' => 'Accord'), array('make' => 'Ford', 'model' => 'F150'), ); ...................
View Replies !
Multidimensional Array Search
I have a multidimensional array on football statistics. I need to search the array for a specific team, and return that teams key (which row the teams statistics are in). Code:
View Replies !
Multidimensional Array Problem
I have the following multimensional Array: Array ( [Cadence Healthcare,Montreal,Canada] => Array ( [0] => 0 [1] => 2 ) [Merck,London,Canada] => Array ( [0] => 1 ) ) I want to be able to assign in a array: Last_Name[0] = Cadence Healthcare,Montreal,Canada Last_Name[1] = Merck,London,Canada Last_Name[2] = Cadence Healthcare,Montreal,Canada
View Replies !
Grouping Multidimensional Array
I have a 3D array that I'm trying to traverse and wondering the best way to group results? The query returns category | item | note 3 | 1200 | socks 3 | 1440 | stockings 8 | 400 | wool hat How can I group these? PHP Code:
View Replies !
Searching Multidimensional Array
Here is the array. $playerarray = Array ( [0] => Array ( [Team] => jimmydee2 [Player1] => jimmydee2 ) [1] => Array ( [Team] => jimmydee2 [Player1] => jimmydee2 ) ); here is my code to search it for a variable foreach($playerarray as $key => $v){ if($v == "$userid"){ do something; // if userid is in array } } I need to see if the variable $userid is anywhere in the array but doesnt seem to be working. Is it syntax or the way I am trying to do it.
View Replies !
Array_push Into Multidimensional Array
I have developed some code to try and push a generated array into an existing array that is pulled from a database then reinsert it. But I dont think my array is being populated. If some one could have a look and tell me where I am going wrong it would be greatly appreciated. Here is my code. $recievearray = mysql_query("SELECT players FROM users WHERE players='$tnumber"); $recievearrayresults = mysql_fetch_array($recievearray); $playerarray = unserialize($recievearrayresults['players']); $playerarraycount = count($playerarray); array_push($playerarray,array(Player1 => $userid, RegNumber => $playerarraycount+1, Rating => $rec['Rating'])); $newplayerarray = serialize($playerarray); Then I reinsert it back into the database with a query.
View Replies !
Was Using Mysql_fetch_assoc, Now Trying Multidimensional Array
I am having trouble getting this loop to do what I would like it to. I need to display information from a multidimensional array in order. The order has already been sorted in the array using a usort. How do I display this information the correct way? I previously used mysql_fetch_assoc and returned stored values of win, ties, and losses. Now I have written a function which evaluates each game and determines winners and losers and ties and then puts all the information in an array. Code:
View Replies !
Array Sorting (multidimensional)
I have an array: array(2) { [0]=> array(1) { ["pageID"]=> string(1) "8" } [1]=> array(1) { ["thematch"]=> float(1.34) } [2]=> array(1) { ["table"]=> string(2) "ct" } [3]=> array(1) { ["pageID"]=> string(1) "6" } [4]=> array(1) { ["thematch"]=> float(1.33) } [5]=> array(1) { ["table"]=> string(2) "ct" } } The problem - I want to sort this array by the second level key value of "thematch". I've tried using the various sort, ksort, asort etc but to no avail. Can someone suggest a way to sort this array by the value (in descending order) of that key?
View Replies !
Sorting Multidimensional Array
I have a multidimensional array that i need to sort by value. An example of the array is as follows $myarray[0]['price']=1400; $myarray[0]['txt']="my arrays txt"; $myarray[0]['acer']="5"; $myarray[1]['price']=1500; $myarray[1]['txt']="my arrays txt 2"; $myarray[1]['acer']="1";
View Replies !
Multidimensional Array In A Loop
How could you define a multi dimensional array in another multidimensional array. $pidcounter = 0; foreach ($invoicenumlist as $key => $value){ foreach ($invoicenumlist[$key] as $key1 => $value1){ $query3 = "SELECT * FROM productid where invoicenum = '$value1'"; $Result3 = mysql_query($query3); while ($row3=mysql_fetch_array($Result3)){ $productidlist[$key][]=$row3['productid']; $pidcounter = $pidcounter+1; } } }
View Replies !
Item In A Multidimensional Array
I have a multidimensional array (I think). It is an array that has arrays inside it. The inside arrays all have the same structure, (qty, product, color, size). How do I count how many items are 'White' * qty? I looked into the php manual and found array_count_values but others say it doesn't work with MD arrays.:confused: array( [0] array([0]qty, [1]product, [2] color, [3] size) [1] array([0]qty, [1]product, [2] color, [3] size) [2] array([0]qty, [1]product, [2] color, [3] size) [3] array([0]qty, [1]product, [2] color, [3] size) [4] array([0]qty, [1]product, [2] color, [3] size) [5] array([0]qty, [1]product, [2] color, [3] size) [6] array([0]qty, [1]product, [2] color, [3] size) ...)
View Replies !
Arrays :: Multidimensional $array
I have a multidimensional $array. (stop me at any point if I'm wrong). Keys are things like [0] => [guid] [link] [title][desc], [1] => [guid] [link] [title][desc] etc. Values have HTML. I array_popped the last item [24] off and exploded out the [desc] key into $new_array. When printed, the array resolves itself into a lovely associative array. I want to crawl the $new_array's values for a string. Let's say, a username. If the username is in that key's v alue, I want to grab the whole value and explode it some more for db storage. So far all attemps at searching have failed. There is only one key in the array that has the value I want, but it's never in the same place depending on when I am pulling the feed.
View Replies !
Multidimensional Array Issue
Can I use array_push to push a full array into another array to make a multidimensional array. Here is my code: $detailsarray = array(Teamname => $userid, Player1 => $userid, Player2 => $Player2); array_push($playerarray,$detailsarray); I need this to keep track of players in an event. When the new array is created I update the database and that can then be pulled on another page to see who is in the event. When a new person signs up then they are just added to the end of the array with there team details. Am I going about this the right way?
View Replies !
Sorting A Multidimensional Array On Two Columns
I'm working on some low-tech sort of content managing system. It uses textfiles as a kind of database so the users don't have to install SQL on their server. Now I want to perform some sorting on my files. These are the contents of one of those files. PageName;Template;Menu;Sub; Introductie;1;1;1; Opnemen;1;2;0; Voorbereidingen;1;2;2; Kwaliteit;1;1;0; Blabla;1;2;1; I first read this file into $someArray with file() and then I parse each row with explode() into columns. So $someArray[2][2] contains the value 2 and $someArray[0][2] contains "Sub". I want to sort this array on both Menu and Sub and write it back to the file. It should look like this. PageName;Template;Menu;Sub; Kwaliteit;1;1;0; Introductie;1;1;1; Opnemen;1;2;0; Blabla;1;2;1; Voorbereidingen;1;2;2; I want to make a list of menus and their listed submenus in the proper order, as you can see . What is the clever way to do this? At this moment I use a loop that sorts the submenu in a loop that finds the right menu in a loop that sorts the menus. No, it's not you, I don't understand it myself anymore. That's because I don't understand most of the array principles and functions.
View Replies !
Copying A Multidimensional Array To $_SESSION
Specifically, is it possible to copy a multidimensional array into the $_SESSION array - ie a deep clone of all keys and data? I naively assumed that $_SESSION["myArray"'] = $myArray ; would work but it doesn't appear to work. Is there a single function or assignment I can use, or would I need to use a "foreach" at every level?
View Replies !
Multidimensional Associatve Array Problem
from a MySQL DB i want to get a multidimensional array that i can loop through either key =field name value = array of ENUM options or array[x][0] =field name, array[x][1]= ENUM options and increment x inside loop $q=mysql_query("SHOW FIELDS FROM table" ) or die ("Query failed"); while ($row = mysql_fetch_array($q)) { //from http://uk.php.net/mysql_fetch_field echo 'field is '.$row['Field'] . ' type is ' . $row['Type']; if (ereg('enum.(.*).', $row['Field'], $match)) { $opts = explode(',', $match[1]); foreach ($opts as $item) {$finalResult[] = substr($item, 1, strlen($item)-2);} } $array=array ($row['Field'] =>$finalResult[]); } gives Fatal error :Cannot use [] for reading in ....... a similar error message when i try a multidimentional array array[$x][0]=$row['Field'] array[$x][1]=$finalResult[]
View Replies !
|