Всем доброе время суток! Уже задал вопрос на другом форуме, но ответа пока что не получил, может здесь найду ответ. Есть код: PHP: <?php $client = new SoapClient("http://xxx.ru/WCF/ClientService.svc?wsdl"); $params = array ( 'login' => 'test', 'password' => 'test', 'filter' => array( 'season_list' => array(0 => 'w'), 'width_min' => 185, 'width_max' => 185, 'height_min' => 60, 'height_max' => 60, 'diameter_min' => 15, 'diameter_max' => 15, ), 'page' => 0, ); $answer = $client->GetFindTyre($params); Мне нужно перебрать элементы массива, делаю так - PHP: for ($index = 0; $index < count($answer->GetFindTyreResult->price_rest_list->TyrePriceRest); $index++){ foreach ($answer->GetFindTyreResult->price_rest_list->TyrePriceRest[$index] as $value) { print_r($value); Вывод print_r($value) - 2884F5153Nhttp://xxx.ru/pictures/tyres/Yokohama/iceGuard_Stud_iG35/big/1.png http://xxx.ru/pictures/tyres/Yokohama/iceGuard_Stud_iG35/small/1.png YokohamaiceGuard Stud iG35185/60R15 88T XL iceGuard Stud iG35 TL + (шип.)w1carstdClass Object ( [wh_price_rest] => Array ( [0] => stdClass Object ( [price] => 2884 [price_rozn] => 3230 [rest] => 33 [wrh] => 42 ) [1] => stdClass Object ( [price] => 2884 [price_rozn] => 3230 [rest] => 2 [wrh] => 22 ) ) ) 2425500http://xxx.ru/pictures/tyres/Pirelli/Winter_Ice_Zero/big/1.png http://xxx.ru/pictures/tyres/Pirelli....pngPirelliIce Zero185/60R15 88T XL Ice Zero (шип.)w1 carstdClass Object ( [wh_price_rest] => Array ( [0] => stdClass Object ( [price] => 3345 [price_rozn] => 3840 [rest] => 3 [wrh] => 42 ) [1] => stdClass Object ( [price] => 3345 [price_rozn] => 3840 [rest] => 24 [wrh] => 43 ) ) ) 2166983http://xxx.ru/pictures/tyres/Kumho_Marshal/WinterCraft_Ice_WI31/big/1.png http://xxx.ru/pictures/tyres/Kumho_M...halWinterCraft Ice WI31185/60R15 88T XL WinterCraft Ice WI31 (шип.)w1car stdClass Object ( [wh_price_rest] => Array ( [0] => stdClass Object ( [price] => 2683 [price_rozn] => 3000 [rest] => 41 [wrh] => 42 ) [1] => stdClass Object ( [price] => 2683 [price_rozn] => 3000 [rest] => 41 [wrh] => 22 ) [2] => stdClass Object ( [price] => 2683 [price_rozn] => 3000 [rest] => 19 [wrh] => 43 ) [3] => stdClass Object ( [price] => 2683 [price_rozn] => 3000 [rest] => 4 [wrh] => 1 ) ) ) Получаю в принципе то что мне нужно. Но если я начинаю просто выводить это через echo - PHP: echo $value; } } ?> выводит только, как я понимаю значение 1 элемента массива: 2884F5153Nhttp://xxx.ru/pictures/tyres/Yokohama/iceGuard_Stud_iG35/big/1.png http://xxx.ru/pictures/tyres/Yokoham...kohamaiceGuard Stud iG35185/60R15 88T XL iceGuard Stud iG35 TL + (шип.)w1car Помогите, подскажите почему так происходит и как мне вывести этот многомерный массив корректно?
вырвиглаз. А стразами еще можно ? мало красителей в результативном выводе и скопировав не из исходной страницы. Такой вывод лень разбирать. покажи результат print_r ( $answer->GetFindTyreResult->price_rest_list->TyrePriceRest ); Без циклов! Скопировав из исходной страницы ctrl+u И без макияжа! --- Добавлено --- P.s: с циклами код премию ждет за оригинальность
Вот такой вывод: Код (Text): Array ( [0] => stdClass Object ( [code] => 613949 [img_big_my] => [img_big_pish] => http://www.xxx.ru/pictures/tyres/BFGoodrich/G-Force_Stud/big/1.png [img_small] => http://www.xxx.ru/pictures/tyres/BFGoodrich/G-Force_Stud/small/1.png [marka] => BFGoodrich [model] => G-Force Stud [name] => 185/60R15 88Q XL G-Force Stud TL (шип.) [season] => w [thorn] => 1 [type] => car [whpr] => stdClass Object ( [wh_price_rest] => Array ( [0] => stdClass Object ( [price] => 2761 [price_rozn] => 3170 [rest] => 41 [wrh] => 42 ) [1] => stdClass Object ( [price] => 2761 [price_rozn] => 3170 [rest] => 41 [wrh] => 22 ) [2] => stdClass Object ( [price] => 2761 [price_rozn] => 3170 [rest] => 41 [wrh] => 43 ) [3] => stdClass Object ( [price] => 2761 [price_rozn] => 3170 [rest] => 2 [wrh] => 1 ) ) ) ) [1] => stdClass Object ( [code] => 2425500 [img_big_my] => [img_big_pish] => http://www.xxx.ru/pictures/tyres/Pirelli/Winter_Ice_Zero/big/1.png [img_small] => http://www.xxx.ru/pictures/tyres/Pirelli/Winter_Ice_Zero/small/1.png [marka] => Pirelli [model] => Ice Zero [name] => 185/60R15 88T XL Ice Zero (шип.) [season] => w [thorn] => 1 [type] => car [whpr] => stdClass Object ( [wh_price_rest] => Array ( [0] => stdClass Object ( [price] => 3345 [price_rozn] => 3840 [rest] => 3 [wrh] => 42 ) [1] => stdClass Object ( [price] => 3345 [price_rozn] => 3840 [rest] => 20 [wrh] => 43 ) [2] => stdClass Object ( [price] => 3345 [price_rozn] => 3840 [rest] => 20 [wrh] => 1 ) ) ) ) [2] => stdClass Object ( [code] => R0230 [img_big_my] => [img_big_pish] => http://www.xxx.ru/pictures/tyres/Yokohama/iceGuard_Studless_iG50Plus/big/0.png [img_small] => http://www.xxx.ru/pictures/tyres/Yokohama/iceGuard_Studless_iG50Plus/small/0.png [marka] => Yokohama [model] => iceGuard Studless iG50+ [name] => 185/60R15 84Q iceGuard Studless iG50+ [season] => w [thorn] => [type] => car [whpr] => stdClass Object ( [wh_price_rest] => Array ( [0] => stdClass Object ( [price] => 3170 [price_rozn] => 3650 [rest] => 12 [wrh] => 42 ) [1] => stdClass Object ( [price] => 3170 [price_rozn] => 3650 [rest] => 36 [wrh] => 22 ) [2] => stdClass Object ( [price] => 3170 [price_rozn] => 3650 [rest] => 4 [wrh] => 43 ) [3] => stdClass Object ( [price] => 3170 [price_rozn] => 3650 [rest] => 41 [wrh] => 1 ) [4] => stdClass Object ( [price] => 3170 [price_rozn] => 3650 [rest] => 41 [wrh] => 9 ) ) ) ) Цветом хотел помочь, а получилось видимо наоборот ) Ну очень давно не практиковал php, теперь вот решил через насколько лет вернуться в кодинг. Мне главное понять как обработать получаемые данные, красотой и функциональностью кода займусь потом.
это не многомерный массив, а массив объектов. Красиво и читабельно вывести можно вот так: PHP: echo '<pre>'; print_r(/* переменная */); echo '</pre>';
спасибо конечно за подсказки, красиво выводит , но не решает моей проблемы. Мне нужно вывести обычным списком. например: название элемента массива - значение. Код (Text): [0] [code] => 613949 [img_big_my] => [marka] => BFGoodrich [model] => G-Force Stud [name] => 185/60R15 88Q XL G-Force Stud TL (шип.) [season] => w [thorn] => 1 [type] => car [1] [code] => 2425500 [marka] => Pirelli [model] => Ice Zero [name] => 185/60R15 88T XL Ice Zero (шип.) [season] => w [thorn] => 1 [type] => car или в табличном виде, в конечном счете хотелось бы это все оформить.
У вас сейчас такая же структура как и описали достаточно увидеть это возможно путем смены типа содержимого / stdClass разрешит сменить тип его результата. PHP: print_r ( (array)$answer->GetFindTyreResult->price_rest_list->TyrePriceRest ); --- Добавлено --- а вот допустим через цикл пример: PHP: foreach ( $answer->GetFindTyreResult->price_rest_list->TyrePriceRest AS $items ) { printf ( 'код: %d | модель: %s', $items -> code, $items -> model ) . PHP_EOL; } и должно вывести : код: 613949 | модель: G-Force Stud код: 2425500 | модель: Ice Zero ...