SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,395
    Mentioned
    81 Post(s)
    Tagged
    3 Thread(s)

    Working with different arrays created on Windows or Linux

    I am have a problem formating some data from an array. I am getting two different outputs and think the difference is due to Windows or Linux.
    The full code I am using is displayed at the bottom of this page:
    http://www.rubblewebs.co.uk/imagemag...rver/fonts.php

    Selected parts of the output from the arrays are:
    http://www.rubblewebs.co.uk/TESTS/server.png
    http://www.rubblewebs.co.uk/TESTS/local.png

    Currently I am using a function I found on the net and deleting out what I do not need:
    PHP Code:
    // Function to remove items from array
        
    function array_delete$array$filterfor ){ 
           
    $thisarray = array (); 
           foreach( 
    $array as $value 
           if( 
    stristr$value$filterfor ) === false && strlen$value ) > 
           
    $thisarray[] = $value
           return 
    $thisarray
        } 

    // Remove blank lines    
        
    $NoBlanks array_filter$IMarray ); 

    // Remove items containing Name from the arrary
        
    $NoName array_delete$NoBlanks"Name" ); 

    // Remove items containing Path: from the array
        
    $NoPath array_delete$NoName"Path:" ); 

    ETC
    I need to remove the blank lines, lines with --------, lines with Name, lines with Path etc. In fact all I need is the font name

    There must be a better way to do this please could somebody give me a hand.
    Last edited by Rubble; Apr 5, 2009 at 02:07. Reason: Modified the text

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Can you supply the output of the same command on both systems? Maybe piped to a text file?

    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,147
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    PHP Code:
    foreach($fonts as $font) {

        
    $exp preg_split('/\s\s+/',$font);
        echo 
    '<p>',$exp[1],'</p>';


    Not really sure how flexible you need it to be, but that seems to work on your test data.

  4. #4
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,395
    Mentioned
    81 Post(s)
    Tagged
    3 Thread(s)
    Thanks for the replys; I am off out now so just a quick reply and I will try your example later oddz.

    I have copeid and pasted the array into some text files SilverBulletUK:
    http://www.rubblewebs.co.uk/TESTS/server.txt
    http://www.rubblewebs.co.uk/TESTS/local.txt

    The amount of fonts in each array are different and there are 808 items in the local array !


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
  •