If by most efficient, you mean reducing the number of lines in your code, then no, using the method I gave you is the most efficient. For example, $imgname = 123456.jpg:
list($imageNum, $fileext) = split($imgname, ".");
now you can access $imageNum, which contains "123456" -- this is the value you wanted, right?
I want to just extract the 22556 from $imageName and save it as $imageNum.
Yes, you can use regular expressions, and you can explode $imgname and use the first value in the subsequent array. But if all you wanted was to return the image number, my method should work for you. My method has the added bonus of giving you access to the file extension as well, should you need it. In this example, $fileext contains "jpg".