Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8847667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:14:41+00:00 2026-06-14T12:14:41+00:00

I use preg_match_all($pattern, $string, $matches) regularly on data, and basically, I always need to

  • 0

I use preg_match_all($pattern, $string, $matches) regularly on data, and basically, I always need to remove either £0.00 or $0.00 or €0.00 from the array should it be in there.

I never know the position within the array that it will be in, if at all.

I’ve tried unset($matches['£0.00']) and unset($matches[0]['£0.00']) but didn’t work

Also, can it be done without using the actual currency symbol and maybe regex \p{Sc}

So, summary, I have an array of numbers with currency symbols, and need to remove any zero entries.

sample array:

Array ( [0] => Array ( [0] => £18.99 [1] => £0.00 [2] => £0.00 [3] => £0.00 ) ) 

Is this possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:14:42+00:00Added an answer on June 14, 2026 at 12:14 pm

    The usage of preg_match() and preg_match_all() sometimes can be weird

    $matches will be array of the matches to the pattern – in this instance if you

    preg_match("/\p{Sc}0\.00/","£0.00",$matches);
    //$matches[0] => £0.00
    

    or if you add parenthesis () to the pattern you can extract a part

    preg_match("/\p{Sc}(0\.00)/","£0.00",$matches);
    //$matches[0] => £0.00
    //$matches[1] => 0.00
    

    so to solve this problem try this

    foreach($sample_array as $key => $value)
    {
         if(preg_match("/(\$|\p{Sc})0\.00/",$value))
         {
              unset($sample_array[$key]);
         }
    }
    

    Notice the pipe | that denotes $ or £ – if you add another pipe for the euro symbol it will capture that as well – also notice that we are unset()-ing a key in the original array instead of unset()-ing the $matches array

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know how to use preg_match and preg_match_all to find the actual matches of
I use preg_match_all to grab urls and titles from another page and grabbing is
I need to use preg_match_all to repeat occurrence within a given text. eg. input
I have a problem with a regex pattern and optional matches. Basically I try
What pattern i could use in order to get integer value -> 1 from:
I'm trying to build out a preg_match_all so I can use the array, but
I use preg_match_all to grab urls and titles from another page and grabbing is
I want to use preg_match_all to get magnet links from threads then use the
function bb_parse($string, $tags = 'b|i|u|quote|url|img|youtube|user') { $replacement = 0; while (preg_match_all('`\[('.$tags.')=?(.*?)\](.+?)\[/\1\]`', $string, $matches)) foreach
Is there a way to tell preg_match_all to use the third match it finds

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.