I’d like to know why PHP Arrays Suck?? How to store Values in 2D array Dynamically, So that using one value i can access other? also without using indexes.
@Declan1991Jul 24.2008 — #You cannot access an array value without indices in any language. Maybe you should be a little more specific about what your problem is?
@FrankTheTankJul 25.2008 — #You can insert values into an array without specifying an index, like so...
$arrayVal[] = "new thing"; //assigns an index for you
$arrayVal[] = "other new thing"; //assigns another index for you.
You can also access the values without knowing the explicit index values using foreach.
However, as [B]Declan1991[/B] says, you can't touch an array without indexes. In my first example numerical indices will be assigned automatically. The foreach statement will iterate over each index of an array, though you may not know what they are explicitly. php does know what they are and can tell you if you use the foreach($array as $key => $value) version of the foreach statement.
@cktsJul 25.2008 — #I think what you're talking about is what I'm trying to do...
You know how facebook shows a 2 row/3 column table to randomly display 6 of your friends?
I want to know how I can select 6 random friends from the "friends" table in my MySQL database, to display the avatar and friend's name in each column...
I'd like to know why PHP Arrays Suck??[/QUOTE] err, they don't. I'd like to know why you think they do? ? How to store Values in 2D array Dynamically, So that using one value i can access other?
also without using indexes.[/QUOTE]
This really doesn't make a lot of sense. >How to store Values in 2D array Dynamically
Is there any other way?
>So that using one value i can access other?
loop and compare?
>also without using indexes.
You don't like arrays, you don't like indexes. Maybe programming just isn't for you. Have you considered running a cheese shop? ?
I imagine the problem is easier than you might think but without knowing the problem and only being asked for a solution then it's a bit tricky coming up with that solution.
@ckts
You might want to post your own thread about your issue. I don't know how you get Facebook picture profiles from this post? What you need to do is not too hard but I'm not taking the OPs thread of topic. (short answer, little divs in a big div)
@cktsJul 25.2008 — #Because I was thinking that you'd need numbered arrays for output in an HTML file table, because I don't think (and don't know how) you can loop into columns.
And a lot of the stuff on the internet doesn't go clearly into depth about how you take the returned rows and put them into numbered arrays.
@SyCoJul 25.2008 — #ckts this is Komrads thread. His issue is arrays, yours is displaying images in columns. Your issue might be related because it might use arrays but you're dragging it off topic. Arrays are used everywhere in PHP but not all topics need to be posted here.