SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can someone explain (or point me to a resource) what the %s\t%s\n part does in the following code?

    Code:
    while ($report_info = fscanf($fp, "%s\t%s\n")) {
        list ($report_name, $report_full_name) = $report_info;
        if ($report == $report_name) {
    		$report_match = "true";
    		break;
    		}	
    	}
    I'm guessing that it will put the first string it finds into the $report_name variable, then tab over, then the next string into the $report_full_name variable, etc.. I'd like to learn what other options are available with this.. but don't know where to look.

    Thanks!
    - A simple online WYSIWYG editor for HTML code snippets.
    - Managed Web Hosting - $3.95/month (resellers welcome)
    - Why pay more? $8.95 domains & $9.95 SSL certificates!

  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP has a few functions that deal with formated strings such as printf(), sprintf(), and fscanf() as you have in that code (amogst others). These functions are inhereted from the C language, and personally, I don't like them

    The manual has a good explaination of the function fscanf() http://www.php.net/manual/en/function.fscanf.php
    However, the best explaination of how the string formating syntax works is here http://www.php.net/manual/en/function.sprintf.php

    I believe that $report_info will be an array which contains two elements being the two strings extracted in the function call fscanf().
    Last edited by freakysid; May 8, 2001 at 23:17.

  3. #3
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In the following code:
    Code:
    while ($report_info = fscanf($fp, "%s\t%s\n")) {
        list ($report_name, $report_full_name) = $report_info;
        if ($report == $report_name) {		$report_match = "true";		break;		}		}
    The data file has two parts, as follows:
    Code:
    part1      Part2 Goes here
    When I use the code above, it chops off the "Goes here" of Part2. Is there any way to get it to include the whole string of text?

    Thanks.
    - A simple online WYSIWYG editor for HTML code snippets.
    - Managed Web Hosting - $3.95/month (resellers welcome)
    - Why pay more? $8.95 domains & $9.95 SSL certificates!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •