Answer the question
In order to leave comments, you need to log in
How to get a value from a variable?
Good day. Question: I wrote a small parser that takes the article and the price of the product. Used phpquery. Now I need to enter all the data that I pulled out from the competitor’s website into a table. This is where the question arose. The values that I parsed were stored in a variable. I have two of them (article, price).
When these variables are displayed in the table, they are written in one cell. All. How to make each value of a variable be in its own cell?
I am attaching the code:
$file = file_get_contents($url);
$doc = phpQuery::newDocument($file);
foreach ($doc->find('.product-list') as $position) {
$position = pq($position);
$articul = $position->find('.name > span:even(1)')->text();
$price = $position->find('.actions .price')->html();
echo "<pre>";
echo '<table border=1 cellspacing=0 cellpading=0"><th>Артикул</th><th>Цена товара</th>';
echo '<tr>';
echo '<td>'.$articul.'</td>';
echo '<td align="left">'.$price.'</td>';
echo '</tr>';
echo '</table>';
echo "</pre>";
}
Answer the question
In order to leave comments, you need to log in
Well, at least you need to take
echo "<pre>";
echo '<table border=1 cellspacing=0 cellpading=0"><th>Артикул</th><th>Цена товара</th>';
echo '</table>';
echo "</pre>";
It did not give any result. For example, there are 1500 thousand articles in the $ article variable and they are simply written in a row. Now it looks like this:
https://ibb.co/eiezmy
The picture was not loaded, here is a link to the cloud.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question