daxguy Posted January 15, 2011 Share Posted January 15, 2011 I am trying to find a character in the follwing string $string = ' Mumbai Mast Kallander - 02 - Mumbai Mast Kallander'; the character i want to find is '-' and the find how many times does it occur in the string.. can anyone help? Link to comment https://forums.phpfreaks.com/topic/224529-finding-character-in-a-string/ Share on other sites More sharing options...
Pikachu2000 Posted January 15, 2011 Share Posted January 15, 2011 What do you mean by "find it"? If you just want to know if it occurs, and how many times, you can use substr_count for that. Link to comment https://forums.phpfreaks.com/topic/224529-finding-character-in-a-string/#findComment-1159787 Share on other sites More sharing options...
Zurev Posted January 15, 2011 Share Posted January 15, 2011 What do you mean by "find it"? If you just want to know if it occurs, and how many times, you can use substr_count for that. I think you want to use explode just from what I think you're trying to do.... list($series, $episode, $title) = explode(" - ", $string); echo $series; // Mumbai Mast Kallander echo $episode; // 02 echo $title; // Mumbai Mast Kallander Link to comment https://forums.phpfreaks.com/topic/224529-finding-character-in-a-string/#findComment-1159793 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.