Guest Feces lover Posted July 1, 2006 Share Posted July 1, 2006 Is there any PHP function that can output a string at a given position of another string? I've looked through the PHP Manual and couldn't find it. Link to comment https://forums.phpfreaks.com/topic/13381-looking-for-a-php-function/ Share on other sites More sharing options...
Orio Posted July 1, 2006 Share Posted July 1, 2006 Can you give an example?Orio. Link to comment https://forums.phpfreaks.com/topic/13381-looking-for-a-php-function/#findComment-51675 Share on other sites More sharing options...
heckenschutze Posted July 1, 2006 Share Posted July 1, 2006 Try using, substr(), spliting off the first part of the string, inserting your part, and then adding on the end, also found with substr(). Link to comment https://forums.phpfreaks.com/topic/13381-looking-for-a-php-function/#findComment-51678 Share on other sites More sharing options...
Guest Feces lover Posted July 1, 2006 Share Posted July 1, 2006 OK, here's an example. I'm making a PHP chatbotif (stristr($input, 'my') !== FALSE && stristr($input, 'name') !== FALSE){$name = //function that gets the 4th word of $input goes here$response = ("Hello $name!");And I'll try the substr() suggestion. Link to comment https://forums.phpfreaks.com/topic/13381-looking-for-a-php-function/#findComment-51679 Share on other sites More sharing options...
Guest Feces lover Posted July 1, 2006 Share Posted July 1, 2006 I figured out a simple way to do it, which makes me feel really stupid:[code]if (stristr($input, 'my') !== FALSE && stristr($input, 'name') !== FALSE){$name = substr($input, 10);$name = trim ($name, '.');$response = ("Hello $name!");}[/code] Link to comment https://forums.phpfreaks.com/topic/13381-looking-for-a-php-function/#findComment-51689 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.