lemmin Posted August 30, 2007 Share Posted August 30, 2007 The functions array_slice() array_splice() (maybe another few, but I don' think so) are the only array functions that use an offset instead of a key. Normally this wouldn't be a problem, but, as far as I can tell, there are no php functions to aid in finding the offset of a key, or even a value. Of course, you can use different methods of getting the offset of what you are looking for, depending on what you are trying to do, but I'm wondering, is there any way to simplify this? Is it possible to, for example, use array_splice() on one key that you know the name of, without looping through the array looking for that key? These two functions just seem so akward compared to all the other ones. Thanks for any info. Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 30, 2007 Share Posted August 30, 2007 I guess you'd only use it in cases when you knew the offset, such as when you wanted to split it in half. Otherwise, you'd use another function. What are you trying to do? Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 31, 2007 Author Share Posted August 31, 2007 Removing an element from an array is what I would use splice for, or changing the order of an array based on one value. Can this be done with simpler functions (without making my own loop?) 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.