Pull CSV values into array, insert sequentially into string

Links for php scripts

Moderators: egami, macek, gesf

Post Reply
seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Thu Oct 11, 2012 1:13 pm

are you manually populating $widgets_list or is that coming from a site or being generated based on already saved pages? are you doing a full grab every time, or just new additions? sorry, i want to help but need to understand how you want it to work before i can offer any relevant assistance.

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Wed Oct 24, 2012 8:01 am

no problem, in the re-reading it seems pretty straightforward. will add sample code to this post in just a few minutes

***edit***
Try this.

Code: Select all

    <?php

    /* widget url variables */
    $wyoprefix = 'http://www.example.com/widget/view?widgetId=';
    $wyosuffix = '&geoTypeId=1&geoIds=0001&useComp=true&format=html';
	$file=fopen('sample.txt','rb'); //open file for reading
	$contents=fread($file, filesize($file));//read entire file
	$widgets_list = explode(',',$contents);//split on commas and create array
    $widgets_count = count($widgets_list);

    for ($i = 0; $i < $widgets_count; $i++) {
        $fullstring = $wyoprefix . $widgets_list[$i] . $wyosuffix;
       
        /* saved files location on server */
       $destination = 'tables/' . $widgets_list[$i] . '.html';
       
        file_put_contents($destination, file_get_contents($fullstring));
    }

    ?>


Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest