onlyican Posted August 2, 2006 Share Posted August 2, 2006 YoI am going brain dead I think, I swear I done this before, But I cant remember howI have an array with multiple things in there, including itemsI call these by$item1 = $keyarray['item1'];$item2 = $keyarray['item2'];NowI want to make these items into a new arrayso I wont use item1 item2I would use an array called items, and end up with a finish result, something likeArray ( [0] => prod1 [1] => prod2 )How do I do this again?Thanks in advance Link to comment https://forums.phpfreaks.com/topic/16319-stupid-array-question/ Share on other sites More sharing options...
kenrbnsn Posted August 2, 2006 Share Posted August 2, 2006 If I understand what you're looking for, try this:[code]<?php$items = array();foreach ($keyarray as $k => $v) $items[] = $v;echo '<pre>' . print_r($items,true) . '</pre>'; // just to see what's in the array?>[/code]Ken Link to comment https://forums.phpfreaks.com/topic/16319-stupid-array-question/#findComment-67776 Share on other sites More sharing options...
onlyican Posted August 2, 2006 Author Share Posted August 2, 2006 That would not work as there are loads of things in the key arrayI only wanted items.Brain clicked infor($i = 0; $i < $num_items; $i++){$prod = $i +1;$item_name[$i] = $keyarray["item_name".$prod];} Link to comment https://forums.phpfreaks.com/topic/16319-stupid-array-question/#findComment-67781 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.