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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:55:54+00:00 2026-05-30T11:55:54+00:00

Possible Duplicate: how to extract data from csv file in php i’m new on

  • 0

Possible Duplicate:
how to extract data from csv file in php

i’m new on php and now i try to make a private site for me and read out some stock information over yahoo api

Link: finance.yahoo.com/d/quotes.csv?s=^GDAXI+^TECDAX+eurusd=x+gcf12.cmx+CLH12.NYM&f=nl1k2

The link works fine but now how can i read this file out? And echo the information on my page?

Output:

"DAX",6864.43,"+54.97 - +0.81%"
"TECDAX",775.33,"+3.78 - +0.49%"
"EUR to USD",1.3447,"N/A - 0.00%"
"Gold Jan 12",1731.80,"N/A - +0.32%"
"Crude Oil Mar 12",105.88,"N/A - +0.04%"

What i need:

echo $name;
echo $rate;
echo $change;
echo $changeinpercent;

I hope some one can help me, and sry for my bad english.

Greetings,
matthias

  • 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-30T11:55:56+00:00Added an answer on May 30, 2026 at 11:55 am

    You could use RegEx to extract from each line the information you need. The following php code is what you need to extract this specific data. It’s a RegEx code and you should use it with a preg_match function:

    /\"([^\"]+)\",(\d+\.\d+),\"(N\/A)?([+-]?\d+\.?\d+)?\s+-\s+([+-]?\d+\.?\d+%?)/  
    

    It gives you an array, and you will use it as:

    $match[0]  
    $match[1]  
    $match[2]  
    $match[3]  
    

    UPDATE:
    This is the code to do it:

    <?php
    $csv=file_get_contents("http://finance.yahoo.com/d/quotes.csv?s=^GDAXI+^TECDAX+eurusd=x+gcf12.cmx+CLH12.NYM&f=nl1k2");
    
    $rows=explode("\n", $csv);
    
    for($i=0;$i<count($rows);$i++)
    {
        preg_match_all("/\"([^\"]+)\",(\d+\.\d+),\"(N\/A)?([+-]?\d+\.?\d+)?\s+-\s+([+-]?\d+\.?\d+%?)/", $rows[$i],$matches,PREG_SET_ORDER);
    }
    ?>  
    

    It returns:

    Array
    (
       [0] => Array
            (
                [0] => "DAX",6864.43,"+54.97 - +0.81%
                [1] => DAX
                [2] => 6864.43
                [3] => 
                [4] => +54.97
                [5] => +0.81%
            )  
    Array
    (
        [0] => Array
            (
                [0] => "Gold Jan 12",1731.80,"N/A - +0.32%
                [1] => Gold Jan 12
                [2] => 1731.80
                [3] => N/A
                [4] => 
                [5] => +0.32%
            )
    
    )
    

    If it is N/A you will find it in $matches[3], if a value in 4.
    )

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: how to extract plain text from ms word document file in pure
Possible Duplicate: How to extract a node attribute from XML using PHP's DOM Parser
Possible Duplicate: How to extract a file extension in PHP? I have a variable
Possible Duplicate: How to extract img src, title and alt from html using php?
Possible Duplicate: How to extract a file extension in PHP ? For example if
Possible Duplicate: How can I extract images from a PDF file? I am able
Possible Duplicate: How to extract img src, title and alt from html using php?
Possible Duplicate: How to extract img src, title and alt from html using php?
Possible Duplicate: Extract decimal part from a floating point number in C I would
Possible Duplicate: Extracting dollar amounts from existing sql data? I have a column in

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.