Hi Guga, --- Guga <guga@supernix.com.br> wrote: > Hi Christopher; > > the function substr_replace() is what I really need, but have any way to > take the variable total chars? > the text is diferent all the time, and i need to put the new text exactly in > the middle. > i have tried many times, but only errors. Why not go for a simpler solution? If the position of the text to be interpolated inside the other is fixed, it will be simpler to just refer to the variable there, e.g.: $name = 'John Q. Public'; $salutation = "Hello $name!, how is the weather over there?"; If what you need is to replace an existing fixed part, then str_replace() would be the way to go: $salutation = str_replace('[NAME]', $name, 'Hello [NAME]!, how is the weather over there?'); Yet another possibility is simple concatenation: $text = 'Hello !, how is the weather over there?'; $salutation = substr($text,0,6).$name.substr($text,6); When trying to solve something, I tend to use the KISS approach. Usually the simpler solution is the one needed (Occam's razor) BTW, I do not see what this has to do w/ OOP in PHP <grin>, and string interpolation, concatenation and replacement are all already discussed in the _fine_ PHP manual. If the bits to be replaced or extracted for concatenation are variable but follow a patterns, then use any of the preg_* functions (ereg* are OK, but usually slower and the regexes not as rich). Cheers. ===== --- Jesus M. Castagnetto (jcastagnetto@yahoo.com) Research: http://metallo.scripps.edu/ Personal: http://www.castagnetto.org/ __________________________________________________ Do you Yahoo!? Yahoo! Tax Center - forms, calculators, tips, more http://taxes.yahoo.com/ ------------------------ Yahoo! Groups Sponsor ---------------------~--> Get 128 Bit SSL Encryption! http://us.click.yahoo.com/FpY02D/vN2EAA/xGHJAA/saFolB/TM ---------------------------------------------------------------------~-> Look here for Free PHP Classes of objects: http://phpclasses.UpperDesign.com/ To unsubscribe from this group, send an email to: php-objects-unsubscribe@egroups.com Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/