D
D
Dmitry2016-08-03 14:10:12
PHP
Dmitry, 2016-08-03 14:10:12

Please explain the design (PHP)?

Please explain what kind of check is performed in this construction:

if (!(isset($numer['image']))){
            $numer['image'] = '-1';
            $image_path = $html_sub->find('div.product_info div.image div img')[0]->src;
        }

Answer the question

In order to leave comments, you need to log in

4 answer(s)
Y
yociyavi, 2016-08-03
@yociyavi

Checks if $numer['image'] exists, and if it doesn't exist, sets it to "-1"

G
Greg Popov, 2016-08-03
@Gregpopov

If $numer['image']undefined, the method searches for the specified string, before setting the value$numer['image'] = '-1';

D
Dmitry, 2016-08-03
@demonix26

Here is a link from the site tdme.ru/product/nizvolobor/380/#
Present in the table either Photo or Image. It turns out that if there is no tag with the name, then the code will not be executed. But it is being fulfilled.
$table_of_goods = $html_sub->find('div#modal_table table.mod_t')[0]->children;
$table_header = $table_of_goods[0]->find('tr')[0];
$table_body = $table_of_goods[1]->children;
$number = array();
// Pull out the cell numbers with the columns we need
foreach (($table_header->children) as $num => $th_row) {
// echo "FIRST foreach
";
//var_dump($th_row->plaintext);
//var_dump($num);
switch(trim($th_row->plaintext)){
case 'Name':
case 'Light name':
$numer["name"] = $num;
break;
case 'Photo':
case 'Image':
$numer['image'] = $num;
break;
case 'Article':
$numer['model'] = $num;
break;
}
}
if (!(isset($numer['image']))){
$numer['image'] = '-1';
}
//echo "";
$rowspan = 1;

H
hetzerok, 2016-08-03
@hetzerok

What exactly is $numer['image'] in the problem case? php.net/manual/en/types.comparisons.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question