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

  • SEARCH
  • Home
  • 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 897995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:58:15+00:00 2026-05-15T14:58:15+00:00

Array ( [0] => Array ( [0] => 21.2694 USD ) [1] => Array

  • 0

Array ( [0] => Array ( [0] => 21.2694 USD ) [1] => Array ( [0] => 21.2694 USD ) )

(this is basicall google currency converter)

echo $arr[0][0]; //output is 21.2694 usd

But i want Output like 21.26 USD

What is tried is ,
echo substr($arr[0][0],0,5);//For this substr line i expected output is 21.26

But am getting just blank page,

Where i made mistake

i want 21.26USD as the output if i give the input as 21.2694 USD

Basically am doing the currency converter (google api)

But api producing result as 29.5645 USD from in this , i want to make out put as 29.56 USD ,

This is my snippet ,

   
    $from_currency = "GBP";
    $selected_currency = 'USD';
    $txt_cash_price = '10';
    $txt_card_price = '14';

    $get_currency = file_get_contents("http://www.google.com/finance/converter?a=$txt_cash_price&from=$from_currency&to=$selected_currency");
    preg_match_all("/(.*)/", $get_currency, $matches,PREG_PATTERN_ORDER);
    $caprice = $matches[0][0];

       OUPUT SOMTHING LIKE THIS 15.2070 USD

But i want output as 15.20 USD

  • 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-05-15T14:58:16+00:00Added an answer on May 15, 2026 at 2:58 pm

    You can use round

    $str = '15.2070 USD';
    echo round($str,2)." USD"; //15.21 USD
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

array = ['item1', 'item2', 'item3', 'item4'] output = array.toString() This gets me item1,item2,item3,item4 but
Array starts like this: Array ( [SMART Board] => Array ( [0] => sb1
Array.Copy and Buffer.BlockCopy both do the same thing, but BlockCopy is aimed at fast
Array { [0] => http://abc.com/video/ghgh23; [1] => http://smtech.com/file/mwerq2; } I want to replace the
Array $ALLOWED_CALLS contains a function name and required parameters. I'd like to filter $_REQUEST
array = ['blue', 'red', 'green', 'green', 'red', 'blue', 'black', 'blue'] ...the output I'm trying
array ref.length = 7 (0 - 6), and I want to try to match
Array.prototype.push8 = function (num) { this.push(num & 0xFF); }; Array.prototype.push16 = function (num) {
Array selected = Array.CreateInstance(typeof(Object), (this.designer1.DesignerHost.GetService(typeof(ISelectionService)) as ISelectionService).SelectionCount); (this.designer1.DesignerHost.GetService(typeof(ISelectionService)) as ISelectionService).GetSelectedComponents().CopyTo(selected, 0); _PropertyGrid.SelectedObjects = new
array[10]={2,3424,4234,42,234,234,23423,123,342,3} In this array, how do I find the first five biggest numbers and

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.