Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php parse file

$txt_file    = file_get_contents('path/to/file.txt');
$rows        = explode("
", $txt_file);
array_shift($rows);

foreach($rows as $row => $data)
{
    //get row data
    $row_data = explode('^', $data);

    $info[$row]['id']           = $row_data[0];
    $info[$row]['name']         = $row_data[1];
    $info[$row]['description']  = $row_data[2];
    $info[$row]['images']       = $row_data[3];

    //display data
    echo 'Row ' . $row . ' ID: ' . $info[$row]['id'] . '<br />';
    echo 'Row ' . $row . ' NAME: ' . $info[$row]['name'] . '<br />';
    echo 'Row ' . $row . ' DESCRIPTION: ' . $info[$row]['description'] . '<br />';
    echo 'Row ' . $row . ' IMAGES:<br />';

    //display images
    $row_images = explode(',', $info[$row]['images']);

    foreach($row_images as $row_image)
    {
        echo ' - ' . $row_image . '<br />';
    }

    echo '<br />';
}
Comment

PREVIOUS NEXT
Code Example
Php :: php print_r 
Php :: how to add php file in html 
Php :: php date function get previous month 
Php :: migrate specific file in laravel 
Php :: Get current taxonomy term ID of the active page 
Php :: update role spatie 
Php :: laravel collection put 
Php :: laravel assets path 
Php :: add css to gutenberg editor 
Php :: with message in laravel 
Php :: wp shortcode 
Php :: str_ireplace 
Php :: Disable wordpress editor - gutenberg on Post type post 
Php :: laravel command parameter optional 
Php :: clear console php 
Php :: laravel default string length migration 
Php :: get deleted value laravel 
Php :: remove certain haracters from a string php 
Php :: php read mysql 
Php :: laravel price database 
Php :: php has constant 
Php :: apiresource laravel 
Php :: wordpress Warning: Cannot modify header information - headers already sent by 
Php :: delete previous uploaded image when update laravel 
Php :: laravel without global scope 
Php :: drupal 8 get enabled languages 
Php :: laravel model save get id 
Php :: transfer file using file_get_content 
Php :: what is better, php or javascript 
Php :: css not working in live laravel project 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =