Skip to content
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

How to search in range of POSitions? #84

Open
Fayozjon opened this issue Oct 28, 2023 · 1 comment
Open

How to search in range of POSitions? #84

Fayozjon opened this issue Oct 28, 2023 · 1 comment

Comments

@Fayozjon
Copy link

Hello i have table with "TITLES" on it i want to group items between 2 positions of search for example i have
table > tr>td.title and also i have table > tr > td.item one table items and titles are in ONE hierarchy so i want to group .item(s) and make .title as array group key and values .items like category and products

@duzun
Copy link
Owner

duzun commented Nov 6, 2023

Here is a rough example (not tested):

$rows = $doc->find('table > tr > td.title:parent');
$items = [];
foreach($rows as $tr)  {
	$title = $tr->find('>td.title')->first()->text();
	$item = $tr->find('>td.item')->first()->text();
	$items[$title][] = $item;
}

Or you could try to use the dl() method:

$items = $doc->dl('table > tr > td.title', 'table > tr > td.item');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants