Jump to content

Recommended Posts


Hey, I'm having trouble here... how do i modify this code so that the following element is displayed ahead of each "word" in the output..[see bellow]. Also is there a way to count the number of times the occurrences take place (1,2,3 etc). Help.

Quote

<i class="fa fa-tag" aria-hidden="true"></i>

    $str = "Yogurt (Milk), Strawberries (11%), Sugar, Water, Stabilisers: Pectins, Guar Gum, Flavourings, Acidity Regulator: Citric Acid, Yogurt (Milk), Peach (9%), Sugar, Water, Apricot (3%), Stabilisers: Pectins, Guar Gum, Acidity Regulator: Citric Acid, Flavourings";

    $new_str = array_unique(array_map('trim', explode(',', $str)));
    $string = implode(',', $new_str);

    echo $string;
Edited by oz11
  • oz11 changed the title to Remove repeat words from string and do other things
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.