brodywx Posted March 7, 2007 Share Posted March 7, 2007 Can someone tell me if this how to add and array to an array: $arr = array(); $arr[] = array("zero", "0"); $arr[] = array("one", "1"); $arr[] = array("two", "2"); Link to comment https://forums.phpfreaks.com/topic/41678-ahhh-need-help/ Share on other sites More sharing options...
trq Posted March 7, 2007 Share Posted March 7, 2007 Doesn't really make much sense. What exactly are you wanting to do? Link to comment https://forums.phpfreaks.com/topic/41678-ahhh-need-help/#findComment-201969 Share on other sites More sharing options...
suzzane2020 Posted March 7, 2007 Share Posted March 7, 2007 I guess what u want to do is insert elements to an existing array u can use the function array_push('array_name','element1','elemet2') Link to comment https://forums.phpfreaks.com/topic/41678-ahhh-need-help/#findComment-201973 Share on other sites More sharing options...
brodywx Posted March 7, 2007 Author Share Posted March 7, 2007 I want to make a multidimensional array. Using the last example: $arr[0][0] // would be "zero" $arr[1][1] // would be "1" Link to comment https://forums.phpfreaks.com/topic/41678-ahhh-need-help/#findComment-201974 Share on other sites More sharing options...
brodywx Posted March 7, 2007 Author Share Posted March 7, 2007 would array push work like this: array_push($arr, "zero", "0"); Link to comment https://forums.phpfreaks.com/topic/41678-ahhh-need-help/#findComment-201975 Share on other sites More sharing options...
suzzane2020 Posted March 7, 2007 Share Posted March 7, 2007 For multi dimensional arrays Ur array wud look like this: $arr=array("[zero,0]","[one,1]"); array_push($arr,"[two,2]"); The result wud be array("[zero,0]","[one,1]","[two,2]") Link to comment https://forums.phpfreaks.com/topic/41678-ahhh-need-help/#findComment-201986 Share on other sites More sharing options...
trq Posted March 7, 2007 Share Posted March 7, 2007 I want to make a multidimensional array. Using the last example: $arr[0][0] // would be "zero" $arr[1][1] // would be "1" Your code will be fine. Link to comment https://forums.phpfreaks.com/topic/41678-ahhh-need-help/#findComment-201989 Share on other sites More sharing options...
brodywx Posted March 7, 2007 Author Share Posted March 7, 2007 Alright cool, I'll go change my code and see if things start working. Link to comment https://forums.phpfreaks.com/topic/41678-ahhh-need-help/#findComment-201991 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.