LLeoun Posted September 23, 2009 Share Posted September 23, 2009 Hi all, This may be easy but it's been hours and I am not able to find the solution. Please help! Here's my array: Array ( [GetTagCloudResult] => Array ( [TagCloud] => Array ( [0] => Array ( [iD] => 10 [ChannelID] => 46 [PlaylistID] => 68 [searchWord] => sports [searchQuantity] => 3 ) [1] => Array ( [iD] => 11 [ChannelID] => 46 [PlaylistID] => 68 [searchWord] => beauty [searchQuantity] => 3 ) [2] => Array ( [iD] => 12 [ChannelID] => 46 [PlaylistID] => 68 [searchWord] => home [searchQuantity] => 3 ) [3] => Array ( [iD] => 13 [ChannelID] => 46 [PlaylistID] => 68 [searchWord] => recipes [searchQuantity] => 3 ) [4] => Array ( [iD] => 14 [ChannelID] => 46 [PlaylistID] => 68 [searchWord] => electronics [searchQuantity] => 3 ) . . It goes like that until 33 elements. I need to create another array with just the first four elements ... How can I do that? Thanks a ton! Link to comment https://forums.phpfreaks.com/topic/175233-create-an-array-from-another-array/ Share on other sites More sharing options...
Mark Baker Posted September 23, 2009 Share Posted September 23, 2009 array_slice() $newArray = array_slice($oldArray['GetTagCloudResult']['TagCloud'],0,4); Link to comment https://forums.phpfreaks.com/topic/175233-create-an-array-from-another-array/#findComment-923590 Share on other sites More sharing options...
LLeoun Posted September 23, 2009 Author Share Posted September 23, 2009 Mark Baker, you just saved me. Awesome, thank you! Link to comment https://forums.phpfreaks.com/topic/175233-create-an-array-from-another-array/#findComment-923593 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.