remove string after comma in php

$var = 18,542.00;
$var = intval(preg_replace('/[^\d.]/', '', $var));
result :- 18542;
or if you need float
$var = floatval(preg_replace('/[^\d.]/', '', $var));
result :- 18542.00;

4.11
28

                                    preg_replace('/^([^,]*).*$/', '$1', $print);
substr($string, 0, strrpos($string.",", ","));

4.11 (9 Votes)
0
5
1

                                    $print=preg_replace('/^([^,]*).*$/', '$1', $print);

5 (1 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
remove commas and dots from a string in php php remove all comma from array php remove array values comma remove comma in number format php remove string where there is comma php php remove a name seperated by coma from string remove 0 value from comma separated string in php remove value from comma separated string php removelast comma in php remove comma from string in php php remove trailing comma php remove characters from string if comma php regex remove after comma how to remove comma in php multiple comma remove from string in php remove multiple comma from string in php php remove comma from string number remove comma in php remove comma from a string php php remove comma from value remove starting and ending comma from string php how to remove comma from starting and end of string php how to remove comma from string php remove empty comma from string php How to remove empty comma from string php php remove commas from numeric strings remove comma in number php how to remove a value from comma separated string in php remove comma from a string php remove the comma from a number in php php function that remove comma separator on a number php string remove comma and after remove multiple comma php remove comma from end of string php remove comma from array php remove commas from a string in php php function to remove a comma in the array remove digits after comma php remove comma from a number in php how to remove comma from string array in php php remove word from comma separated string php remove comma from number remove all comma from string php remove comma string between the object php php remove all characters after comma create a string out of comma-del text php php remove comma from amount how to remove extra comma from end of stirng php php string delete after comma how to remove one comma from a php in array remove comma at end php how to remove comma from string in php php remove comma from end of string remove comma if infront or end of string php remove commas in array php remove comma php remove comma from number php php remove comma from string remove comma from start and end of string php php remove all comma from string remove comma string php php remove comma from the end of the string remove comma and 00 from php remove comma 00 from php remove comma from price php remove comma from string php remove number after comma php str replace to remove comma php php remove after comma remove all commas from string php remove comma from price in php remove extra comma from string in php remove string comma php remove string and coma from digit in php remove comma from number format php remove comma from number format in php number format remove comma php remove comma from amount laravel how to remove word after semicolon using php replace all after comma php remove string after comma in php remove after comma in php php remove string after comma remove comma number format php remove behind comma php
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source