antmeeks Posted June 14, 2012 Share Posted June 14, 2012 These statements... $b=$Array1[$a]; $c=$Array2[$b]; $d=$Array3[$c]; combined into one statement like: $d=$Array3[$Array2[$Array1[$a]]] ??? I know my example isn't valid, but is it possible to do this kind of consolidation? Link to comment https://forums.phpfreaks.com/topic/264146-is-this-possible/ Share on other sites More sharing options...
scootstah Posted June 14, 2012 Share Posted June 14, 2012 Yes, this is a valid example: $a = array('a1', 'a2', 'a3'); $b = array('b1', 'b2', 'b3'); $c = array('c1', 'c2', 'c3'); $d = array($a, $b, $c); Link to comment https://forums.phpfreaks.com/topic/264146-is-this-possible/#findComment-1353655 Share on other sites More sharing options...
antmeeks Posted June 14, 2012 Author Share Posted June 14, 2012 Sorry, I guess I wasn't clear... I'm not trying to make a multidimensional array out of 3 other arrays, I'm trying to consolidate the compounding of multiple array key values into one variable. Literal from my example: variable '$b' = the value of array1's key that equals whatever is assigned to '$a': $b=$Array1[$a] variable '$c' = the value of array2's key named the value of variable '$b': $c=$Array2[$b] variable '$d' = the value of array3's key named the value of variable '$c': $d=$Array3[$c] So... is it possible to build up the value of var $d with one statement instead of 3? Link to comment https://forums.phpfreaks.com/topic/264146-is-this-possible/#findComment-1353660 Share on other sites More sharing options...
scootstah Posted June 14, 2012 Share Posted June 14, 2012 Oops, I guess I misunderstood you. Your first example would work actually ($d=$Array3[$Array2[$Array1[$a]]]). What are you trying to do? Link to comment https://forums.phpfreaks.com/topic/264146-is-this-possible/#findComment-1353663 Share on other sites More sharing options...
antmeeks Posted June 14, 2012 Author Share Posted June 14, 2012 Doh! I just figured that out right before your post.... You know it's getting late when you post in a forum before even trying it out first... What I wanted to do was nest the arrays into one var - which, as you say, my original post was a completely valid example of: $d=$Array3[$Array2[$Array1[$a]]]; Time for bed. Link to comment https://forums.phpfreaks.com/topic/264146-is-this-possible/#findComment-1353664 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.