Vivid Lust Posted August 23, 2009 Share Posted August 23, 2009 Hi, can anyone give me the code snipped to delete everything after a space. Examples: INPUT: Hello World OUPUT: Hello INPUT: PHP Freaks OUTPUT: PHP I hope someone can helps, thanks very much Jake. Link to comment https://forums.phpfreaks.com/topic/171514-delete-everything-after/ Share on other sites More sharing options...
thebadbad Posted August 23, 2009 Share Posted August 23, 2009 substr('Hello World', start_position, length) will return the part of the string that starts at start_position and is length characters long. strpos('Hello World', ' ') will return the position of the first occurrence of a space in the string, to be used as the length parameter in substr(), when start_position is 0. Link to comment https://forums.phpfreaks.com/topic/171514-delete-everything-after/#findComment-904439 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.