LemonInflux Posted November 6, 2007 Share Posted November 6, 2007 Hello, all. My query is this: Say I have a string like this: $var = afboij|abfouhenh|naxcbejkh|lkj Just random letters, but separated by a |. How do I count the number of |s in the string? Link to comment https://forums.phpfreaks.com/topic/76177-count-occurences-of-something-in-a-string/ Share on other sites More sharing options...
Barand Posted November 6, 2007 Share Posted November 6, 2007 <?php $var = 'afboij|abfouhenh|naxcbejkh|lkj'; echo substr_count($var, '|'); // 3 ?> Link to comment https://forums.phpfreaks.com/topic/76177-count-occurences-of-something-in-a-string/#findComment-385557 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.