raimis100 Posted March 27, 2008 Share Posted March 27, 2008 is there a function which can insert one string in another string ? Quote Link to comment https://forums.phpfreaks.com/topic/98139-insert-function-in-php/ Share on other sites More sharing options...
wildteen88 Posted March 27, 2008 Share Posted March 27, 2008 Do you mean joining two strings together, if so use the concatenation operator (.) $string1 = 'Hello world!'; $string2 = ' Nice to see you!'; // concatenate the two string together echo $string1 . $string2; Quote Link to comment https://forums.phpfreaks.com/topic/98139-insert-function-in-php/#findComment-502046 Share on other sites More sharing options...
raimis100 Posted March 27, 2008 Author Share Posted March 27, 2008 Yea , thats should work but If I for exemple need to insert char 'h' between 'pp' ; Can't I just use one function to do it ? Quote Link to comment https://forums.phpfreaks.com/topic/98139-insert-function-in-php/#findComment-502047 Share on other sites More sharing options...
wildteen88 Posted March 27, 2008 Share Posted March 27, 2008 There is not a function as such to insert a character between another set of characters However you can do it this way: $chars = 'pp'; $new_str = $chars{0}.'h'.$chars{1}; echo $new_str; Quote Link to comment https://forums.phpfreaks.com/topic/98139-insert-function-in-php/#findComment-502058 Share on other sites More sharing options...
raimis100 Posted March 27, 2008 Author Share Posted March 27, 2008 thats what I needed , lol Thnx Quote Link to comment https://forums.phpfreaks.com/topic/98139-insert-function-in-php/#findComment-502065 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.