Thread: Array Slicing
View Single Post
  #1  
Old 11-09-2009, 06:02 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Array Slicing

This is probably a bit of a large request because it involves the syntax of the language itself, but having slicing syntax similar to that of Python would be really useful.
For example:
PHP Code:
foo "bar";
baz foo[0:1]; // return a slice from index 0 to 1
echo(baz);      // will echo "ba"
baz foo[:-1]; // return a slice from the end
echo(baz;       // will echo "r" 
It's extremely useful and shortens common string and array operations greatly.
Really, better support for treating strings as arrays in general would be nice.
Reply With Quote