I have several categories; some of them have subcategories. The double colon (:🙂 is the delimiter between the subcategories.
$item[1] = 'Food';
$item[2] = 'Food::Bottled_Water';
$item[3] = 'Food::Candy';
$item[4] = 'Food::Candy::Burstin_Bits';
$item[5] = 'Food::Candy::Chocolate';
I need to strip off everything except the last (sub)category. For example:
'Food' above is fine.
For 'Food::Bottled_Water', I just need 'Bottled_Water'.
For 'Food::Candy::Chocolate', I just need "Chocolate".
Is there a quick way to loop through the strings above to strip away what I don't need?
(I thought about using explode(), but the needed string would not necessarily appear as the same array piece for each one.)