in Education by
This question already has answers here: Closed 9 years ago. Possible Duplicate: PHP: unformat money How to get rid of everything that is not a number or dot, replacing , with . using a light regex? Examples: $50.45 = 50.45 USD 50.45 = 50.45 50,45 = 50.45 USD$ 50.45 = 50.45 JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
<?php $money = array( '$50.45', 'USD 50.45', '50,45', 'USD$ 50.45' ); // remove everything except a digit "0-9", a comma ",", and a dot "." $money = preg_replace('/[^\d,\.]/', '', $money); // replace the comma with a dot, in the number format ",12" or ",43" $money = preg_replace('/,(\d{2})$/', '.$1', $money); print_r($money); ?> Output: Array ( [0] => 50.45 [1] => 50.45 [2] => 50.45 [3] => 50.45 )

Related questions

0 votes
    This question already has answers here: Closed 9 years ago. Possible Duplicate: PHP: unformat money How to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 4, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Closed 9 years ago. Possible Duplicate: PHP: unformat money How to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: How do I properly escape quotes inside HTML attributes? (6 answers) Closed 3 years ago....
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I've always just FTPed files down from sites, edited them and put them back up when creating sites, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 23, 2022 in Education by JackTerrance
0 votes
    I am having problems with the event handler in my office addin . Below is an example code i got ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    How To Clean Up Your Amazon Ec2 Instance And Volume ?...
asked Mar 12, 2021 in Technology by JackTerrance
0 votes
    Why initialize and clean up in object studio is necessary in Blue prism?...
asked Nov 6, 2020 in Technology by JackTerrance
0 votes
    I am aware that I can use array_unique(array_merge($a,$b)); to merge two arrays and then remove ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 14, 2022 in Education by JackTerrance
0 votes
    Recently I asked a question regarding preg_match_all with php, and i got the perfect solution as expected ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 11, 2022 in Education by JackTerrance
0 votes
    I'm trying to insert data to the database and at the same time uploading an image to the path. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 2, 2022 in Education by JackTerrance
0 votes
    I want to load Google fonts in the head-section of my page using a php-function. My -area looks like this: ... ... Now ... I do this, there will be a "1" displayed (because of the...
asked Jun 2, 2022 in Education by JackTerrance
0 votes
    I want to load Google fonts in the head-section of my page using a php-function. My -area looks like this: ... ... Now ... I do this, there will be a "1" displayed (because of the...
asked May 30, 2022 in Education by JackTerrance
0 votes
    I want to load Google fonts in the head-section of my page using a php-function. My -area looks like this: ... ... Now ... I do this, there will be a "1" displayed (because of the...
asked May 26, 2022 in Education by JackTerrance
0 votes
    I've following two path path1- test/hello/hello.php path2- test/hello1/hello1.php //notice the one ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 19, 2022 in Education by JackTerrance
0 votes
    In Laravel, there is a function return back();, which returns the user to the previous page. Is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 19, 2022 in Education by JackTerrance
...