tastro Posted October 26, 2010 Share Posted October 26, 2010 also i want to change this array: $a=array('a','b','c','d','e','f','g'); to this: $a=array('a','b','c'); i found out that i can unset the last ones, but is there an other way to do that? faster? Quote Link to comment Share on other sites More sharing options...
tastro Posted October 26, 2010 Author Share Posted October 26, 2010 found it! for ($x=0; $x<3; $x++) { $b[$x]=$a[$x]; } Quote Link to comment Share on other sites More sharing options...
litebearer Posted October 26, 2010 Share Posted October 26, 2010 http://www.php.net/manual/en/function.array-slice.php Quote Link to comment Share on other sites More sharing options...
tastro Posted October 26, 2010 Author Share Posted October 26, 2010 tnx litebear this should work better i think, more efficient. $a=array('a','b','c','d','e','f','g'); $b = (array_slice($a, 0, 3); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.