Tesla wrote:
Hey guys, I have a string like "lalala: djkahsd : dajkdassd : adasd :"
Is there a function to find the position of the "I"th occurence of a
character/string? Like lets say I want to find out the position of the
second colon. How do I go about that?? I can only find functions that
return the position of the first or last occurence, but not a variable
occurence ::sniffles::
Well, you could explode the string at the colons and get
$arr[0] = 'lalala';
$arr[1] = ' djkahsd ';
$arr[2] = ' dajkdassd';
$arr[3] = ' adasd ';
$arr[4] = '';
<?php
$string = "lalala: djkahsd : dajkdassd : adasd :";
$arr = explode(':', $string);
?>
But, if you really want the position of the nth ocurrence of needle in
haystack, I guess your best bet is to make a function that returns that
(or false if not enough needles are in haystack)
or use the array above and get the position as a sum of strlen()s, but I
prefer a specific function :)
Happy Coding :)
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--