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 7907017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:13:44+00:00 2026-06-03T11:13:44+00:00

function get_only_numbers($string){ $getonly = str_split(0123456789); $string = str_split($string); foreach($string as $i => $c){ if(!in_array($c,

  • 0
function get_only_numbers($string){
    $getonly = str_split("0123456789");
    $string = str_split($string);
    foreach($string as $i => $c){
        if(!in_array($c, $getonly))
            unset($string[$i]);
    }
    return implode("", $string);
}

echo get_only_numbers("U$ 499,50"); // prints 49950

This function is supposed to return only the numbers from a string.
Has this function been coded properly?

  • 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-03T11:13:49+00:00Added an answer on June 3, 2026 at 11:13 am

    I think a single call to preg_replace can do that as well:

    preg_replace('/\D+/', '', 'U$ 499,50'); // returns "49950"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

function get_arr($arr) { unset($arr[0]); } $arr1 = array(1,2); $arr2 = array(1,2); get_arr(&$arr1); get_arr($arr2); echo
I have strings which contains thousand separators, however no string-to-number function wants to consume
I want to program a function that generates a String. The String contains only
In php and java there are explode and tokenizer function to convert a string
I have to implement a function to get headers only (without doing a GET
How do I get this function to not only run on window resize but
document.onkeydown.toString() returns onkeydown function but I only want to get this function's name. Is
I get error: ORA-06575: Package or function GET_CONC_NAMES is in an invalid state When
I've a php function to get some data from mysql database: function get_persons() {
Can anyone describe the following php function: function get_setting_value($settings_array, $setting_name, $default_value = ) {

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.