-
-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding TabularDataReader::value method
- Loading branch information
Showing
10 changed files
with
121 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,7 +110,7 @@ var_dump([...$records][0]); | |
<p class="message-notice">full mapper usage was completed in version <code>9.12</code> for <code>Reader</code> and <code>ResultSet</code></code>.</p> | ||
<p class="message-notice">Added in version <code>9.6.0</code> for <code>ResultSet</code>.</p> | ||
|
||
### first and nth | ||
### value, first and nth | ||
|
||
You may access any record using its offset starting at `0` in the collection using the `nth` method. | ||
if no record is found, an empty `array` is returned. | ||
|
@@ -143,6 +143,31 @@ As an alias to `nth`, the `first` method returns the first record from the insta | |
|
||
<p class="message-notice">Added in version <code>9.9.0</code> for <code>Reader</code> and <code>ResultSet</code>.</p> | ||
|
||
If you are only interested in retrieving a specific value from a single row, you can use | ||
the `value` method. By default, it will return the first record item, but you are free | ||
to specify a specific column using the column name if the header is set and/or the | ||
column offset, If no column is found `null` is returned. | ||
|
||
```php | ||
use League\Csv\Reader; | ||
use League\Csv\Statement; | ||
|
||
$reader = Reader::createFromPath('/path/to/my/file.csv', 'r'); | ||
$reader->setHeaderOffset(0); | ||
|
||
$stmt = Statement::create() | ||
->offset(10) | ||
->limit(12) | ||
; | ||
$result = $stmt->process($reader); | ||
$result->value(2); //returns '[email protected]' | ||
$result->value('email'); //returns '[email protected]' | ||
$result->value('toto'); //returns null | ||
$result->value(42); //returns null | ||
``` | ||
|
||
<p class="message-notice">Added in version <code>9.12.0</code> for <code>Reader</code> and <code>ResultSet</code>.</p> | ||
|
||
### exists | ||
|
||
Tests for the existence of a record that satisfies a given predicate. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters