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

Ask A Question

Stats

  • Questions 505k
  • Answers 505k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer What do you mean by "a sequence"? You could turn… May 16, 2026 at 3:24 pm
  • Editorial Team
    Editorial Team added an answer (Full disclosure: I'm on the VS Profiler team) Visual Studio… May 16, 2026 at 3:24 pm
  • Editorial Team
    Editorial Team added an answer Check your service's properties in services.msc to see where your… May 16, 2026 at 3:24 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have an array which looks like this $dataArray = array ( 0 =>
Array.Copy and Buffer.BlockCopy both do the same thing, but BlockCopy is aimed at fast
I have an array of elements. If I do a arr.max I will get
Array 1 | Array 2 ================= 1 | 2 2 | 3 3 |
Array $imagelist: Array ( [additional] => Array ( [count] => 2 [image] => Array
Array ( [kanye] => Array ( [0] => Kanya [1] => Janaye [2] =>
array(1) { [0]=> string(8) outgoing } bool(false) array(1) { [0]=> string(8) outgoing } bool(false)
Array.Sort(test); Comes out to be _A _B _C A B C I reverse it
Array ( [id] => 3 [user_id] => 1 [clan_id] => 1 [date] => 2009-09-24
array array_splice ( array &$input , int $offset [, int $length = 0 [,

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.