String Manipulation
Posted: Tue Sep 23, 2008 4:32 pm
Hello all.
I am new to PHP and I hope my question is simply a matter of overlooking the obvious. I have looked at many sites, including php.net, and I cannot find a way to elegantly manipulate a string (or array) in a manner I want.
I want to simply -- either through intrinsic or user-defined function -- update a value in a semi-colon-delimited string/array. For example, I would want to replace the sixth value in a string.
HAVE : 0;0;0;1;some_data;UNWANTED_DATA;0;0;1
WANT : 0;0;0;1;some_data;NEW_DATA;0;0;1
Does it require a loop to with a nested if statement? Is it a RegEx situation?
All help is appreciated.
I am new to PHP and I hope my question is simply a matter of overlooking the obvious. I have looked at many sites, including php.net, and I cannot find a way to elegantly manipulate a string (or array) in a manner I want.
I want to simply -- either through intrinsic or user-defined function -- update a value in a semi-colon-delimited string/array. For example, I would want to replace the sixth value in a string.
HAVE : 0;0;0;1;some_data;UNWANTED_DATA;0;0;1
WANT : 0;0;0;1;some_data;NEW_DATA;0;0;1
Does it require a loop to with a nested if statement? Is it a RegEx situation?
All help is appreciated.