Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[DomCrawler] Added return of element name inextract() 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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
[DomCrawler] Added return of element name inextract() method#29127
Uh oh!
There was an error while loading.Please reload this page.
Conversation
extract() methodextract() methodjakzal commentedNov 7, 2018
|
andrey-helldar commentedNov 7, 2018
The hardest thing in development is to come up with a variable name. :) I considered different names: I think you're right. |
Uh oh!
There was an error while loading.Please reload this page.
74afc0c to79162c1Comparenicolas-grekas commentedDec 1, 2018
Thank you@andrey-helldar. |
…)` 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#10646Situation: 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.```phpuse 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
… 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()` methodSee a PR:symfony/symfony#29127<!--If your pull request fixes a BUG, use the oldest maintained branch that containsthe bug (seehttps://symfony.com/roadmap for the list of maintained branches).If your pull request documents a NEW FEATURE, use the same Symfony branch wherethe feature was introduced (and `master` for features of unreleased versions).-->Commits-------b89cd59 [DomCrawler] Added return of element name in `extract()` method
amouhzi commentedJan 19, 2019
Hello, And if an attribute with the name |
Uh oh!
There was an error while loading.Please reload this page.
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.