-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DomCrawler] Added return of element name in extract()
method
#29127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nicolas-grekas
merged 1 commit into
symfony:master
from
andrey-helldar:andrey-helldar-patch-1
Dec 1, 2018
Merged
[DomCrawler] Added return of element name in extract()
method
#29127
nicolas-grekas
merged 1 commit into
symfony:master
from
andrey-helldar:andrey-helldar-patch-1
Dec 1, 2018
Conversation
This file contains hidden or 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
andrey-helldar
pushed a commit
to andrey-helldar/symfony-docs
that referenced
this pull request
Nov 7, 2018
extract()
methodextract()
method
|
The hardest thing in development is to come up with a variable name. :) I considered different names: I think you're right. |
ro0NL
approved these changes
Nov 8, 2018
nicolas-grekas
approved these changes
Nov 8, 2018
fabpot
approved these changes
Nov 12, 2018
74afc0c
to
79162c1
Compare
Thank you @andrey-helldar. |
nicolas-grekas
added a commit
that referenced
this pull request
Dec 1, 2018
…)` method (andrey-helldar) This PR was squashed before being merged into the 4.3-dev branch (closes #29127). Discussion ---------- [DomCrawler] Added return of element name in `extract()` method | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | License | MIT | Doc PR | symfony/symfony-docs#10646 Situation: you need to get an array of keys and values. The current package code does not allow this to be done easily. The changes made to the code will allow you to return the required data set. ```php use Symfony\Component\DomCrawler\Crawler; $crawler = new Crawler($content); $crawler ->filter('ItemsList > Item') ->each(function (Crawler $element) { $data = $element ->children() ->extract(['_name', '_text']); var_dump($data); }); // Result: array:2 [ 0 => array:2 [ 0 => "id", 1 => "1" ], 1 => array:2 [ 0 => "title", 1 => "Foo Bar" ] ] ``` Commits ------- 79162c1 [DomCrawler] Added return of element name in `extract()` method
javiereguiluz
added a commit
to symfony/symfony-docs
that referenced
this pull request
Dec 3, 2018
… method (andrey-helldar) This PR was squashed before being merged into the master branch (closes #10646). Discussion ---------- [DomCrawler] Added return of element name in `extract()` method See a PR: symfony/symfony#29127 <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/roadmap for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `master` for features of unreleased versions). --> Commits ------- b89cd59 [DomCrawler] Added return of element name in `extract()` method
Hello, And if an attribute with the name |
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Situation: you need to get an array of keys and values.
The current package code does not allow this to be done easily.
The changes made to the code will allow you to return the required data set.