• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 629
  • Last Modified:

column2 and column3

this is a followup question for
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_27873054.html


http://www.phpkode.com/scripts/item/simple-xlsx/
<?php

include 'simplexlsx.class.php';

$xlsx = new SimpleXLSX('countries_and_population.xlsx');
echo '<h1>$xlsx->rows()</h1>';
echo '<pre>';
print_r( $xlsx->rows() );
echo '</pre>';

echo '<h1>$xlsx->rowsEx()</h1>';
echo '<pre>';
print_r( $xlsx->rowsEx() );
echo '</pre>';

?>

Open in new window




$xlsx->rows()
Array
(
    [0] => Array
        (
            [0] => Rank
            [1] => Country / Territory
            [2] => Population
            [3] => Date of estimate
            [4] =>  % of World population
        )

    [1] => Array
        (
            [0] => 1
            [1] =>  People's Republic of Chinan2
            [2] => 1,341,300,000
            [3] => December 21, 2010
            [4] => 0.195
        )

    [2] => Array
        (
            [0] => 2
            [1] =>  India
            [2] => 1,191,730,000
            [3] => December 21, 2010
            [4] => 0.173
        )

    [3] => Array
        (
            [0] => 3
            [1] =>  United States
            [2] => 310,951,000
            [3] => December 21, 2010
            [4] => 0.0451
        )

Open in new window



I only want the second row
column2 and column3
0
rgb192
Asked:
rgb192
  • 2
  • 2
1 Solution
 
Ray PaseurCommented:
Untested, but something like this:

// GET ALL ROWS
$rows = $xlsx->rows();

// DISCARD THE FIRST ROW
array_shift($rows);

// GET SECOND ROW
$row = array_shift($rows);
$country = $row[1];
$population = $row[2];
0
 
rgb192Author Commented:
Warning: array_shift() [function.array-shift]: The argument should be an array
0
 
Ray PaseurCommented:
Use var_dump() to print out the contents of the variables.  Print the contents of $xlsx->rows() first.
0
 
rgb192Author Commented:
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now