Monday, September 13, 2010

Insert a string into a string given an index

Programmer Question

Hi,



I know this is a really simple question, but I was just wondering if there is a native php method to inject a string into another string. My usual response to a new text manipulation is to consult the manual's listings of string functions. But I didn't see any native methods for explicitly inserting a string into another string so I figured i'd consult SO.



The answer is likely some kind of combination of the php native string functions OR simply regex (which makes my eye's bleed and my brain melt so I avoid it).



EX:
Take a string like some-image.jpg and inject .big before .jpg yielding some-image.big.jpg



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails