473,388 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Array of array...please help

Still having problem with array of arrays. Here is the code:

echo("Name:
".$res["XMLTREE"]["DATAS"][0]["MODELE"]["0"]["MODELNAME"]."<br>");
//$res["XMLTREE"]["DATAS"][0]["MODELE"] is an array with many MODELNAME
while(list($k,$v) = each($res["XMLTREE"]["DATAS"][0]["MODELE"])){
echo("Name: ".$res[$k]["0"]["MODELNAME"]."<br>");

While the first line (the echo) works fine, the echo in the "while" doesn't
work.

I've already created a function by passing such reference:
function printtree($array, $level){
while(list($k,$v) = each($array)){
if(is_array($array[$k])){ //go into the array and print elements
print("$k -><br>");
$level++;
printtree($array[$k],$level);
}
else
print("$k : $v<br>");
}
}

this works just fine !!!!

Get crazy....

BoB

Jul 17 '05 #1
1 1526
Sorry, found...
here is the solution (for interested people...)

echo("Name:".$res["XMLTREE"]["DATAS"][0]["MODELE"]["0"]["MODELNAME"]."<br>")
;
while(list($k,$v) = each($res["XMLTREE"]["DATAS"][0]["MODELE"])){
//wrong: echo("Name: ".$res[$k]["0"]["MODELNAME"]."<br>");
echo("Name: ".$res[$k]["MODELNAME"]."<br>");
//the ["0"] is included in the $k element

BoB

"Bob Bedford" <be******@YouKnowWhatToDoHerehotmail.com> a écrit dans le
message de news:40***********************@news.sunrise.ch...
Still having problem with array of arrays. Here is the code:

echo("Name:
".$res["XMLTREE"]["DATAS"][0]["MODELE"]["0"]["MODELNAME"]."<br>");
//$res["XMLTREE"]["DATAS"][0]["MODELE"] is an array with many MODELNAME
while(list($k,$v) = each($res["XMLTREE"]["DATAS"][0]["MODELE"])){
echo("Name: ".$res[$k]["0"]["MODELNAME"]."<br>");

While the first line (the echo) works fine, the echo in the "while" doesn't work.

I've already created a function by passing such reference:
function printtree($array, $level){
while(list($k,$v) = each($array)){
if(is_array($array[$k])){ //go into the array and print elements
print("$k -><br>");
$level++;
printtree($array[$k],$level);
}
else
print("$k : $v<br>");
}
}

this works just fine !!!!

Get crazy....

BoB


Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Roy J | last post by:
Hello everyone:) My name is Roy, I am new to Java and I have problem regarding to arrays. if you have time and like to help, please help. I am trying to make a program to deal with prime...
0
by: Stephen | last post by:
I was wondering if someone could please help me with an array I'd like to create in an asp.net page. I have to design an array which stores the values of addresses manually entered into textboxes...
13
by: Kevin | last post by:
Help! Why are none of these valid? var arrayName = new Array(); arrayName = new Array('alpha_val', 1); arrayName = ; I'm creating/writing the array on the server side from Perl, but I
1
by: Stephen | last post by:
Was wondering if someone could please help me with an array I'd like to create in an asp.net page. I have to design an array which stores the values of addresses manually entered into textboxes...
33
by: Peace | last post by:
I am having trouble writing code to turn an array into a delimited string. Dim splitout As String splitout = Join(DataArray(rows, columns), " ") rows and columns are integers representing rows...
0
by: sebascomeau | last post by:
Hi everyone, Hello my name is Sebastien and I need some help. He have one week past and I search to do one thing but I can't. If someone help me, I'll be so happy :). My problem is I want to...
44
by: svata | last post by:
Hello, I wonder how to resize such array of structures using realloc()? #include <stdio.h> #include <stdlib.h> #define FIRST 7 typedef struct { char *name;
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
11
by: Sudzzz | last post by:
Hi, I'm trying to convert a string something like this "{201,23,240,56,23,45,34,23}" into an array in C++ Please help. Thanks, Sudzzz
6
by: =?Utf-8?B?Sm9obiBCdW5keQ==?= | last post by:
Hey guys, I've searched high and low for a way to populate a vb array with data from a javascript array. I can find 50 ways to do it with ASP but not one for VB. I appreciate what help you can...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.