samcadek Posted April 4, 2022 Share Posted April 4, 2022 <?php $url = "https://api2.prices.tf/prices/".$datas["def_index"]."%3B".$datas["quality"]; $curl = curl_init($url); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $headers = array( "accept: application/json", "Authorization: Bearer " .$value. " ", ); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); //for debug only! curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $resp = curl_exec($curl); curl_close($curl); var_dump($resp); foreach ($inventories['rgDescriptions'] as $key => $description) { $samik = $description['app_data']; echo $datas["def_index"]."<br>"; echo $datas["quality"]; $unusual = $description['name_color']; if($unusual === "8650AC"){ //do something with it $icon_url = $description['icon_url']; //$count = count($description['descriptions']); foreach ($description['descriptions'] as $key => $effects) { $effectsValue = $effects['value']; if (strpos($effectsValue, '★ Unusual Effect') !== false) { $effectValue = $effects['value']; //$effectColor = $effects['color']; } /* if (str_contains($effectsValue, '★ Unusual Effect')) { $effectValue = $effects['value']; $effectColor = $effects['color']; } */ } //$effectValue = $description['descriptions'][1]['value']; //$effectColor = $description['descriptions'][1]['color']; echo $effectValue; //echo $effectColor; echo ' <div class="item"> <img src="http://cdn.steamcommunity.com/economy/image/' . $icon_url . '/100fx60f" /> <br /> ' . $description['market_name'] . ' </div> '; }else{ $description['appid']; $description['market_name']; $icon_url = $description['icon_url'];echo ' <div class="item"> <img src="http://cdn.steamcommunity.com/economy/image/' . $icon_url . '/100fx60f" /> <br /> ' . $description['market_name'] . ' </div> '; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/314661-hello-i-need-help-with-getting-this-url-value-into-the-foreach-without-the-var-dump-because-it-causes-a-big-loading-time/ Share on other sites More sharing options...
requinix Posted April 4, 2022 Share Posted April 4, 2022 Quote Hello I need help with getting this url value into the foreach without the var dump because it causes a big loading time That would be a great description for someone who was already familiar with everything you were doing and was watching over your shoulder as you tried to tackle this problem. We are neither. 1 Quote Link to comment https://forums.phpfreaks.com/topic/314661-hello-i-need-help-with-getting-this-url-value-into-the-foreach-without-the-var-dump-because-it-causes-a-big-loading-time/#findComment-1594863 Share on other sites More sharing options...
samcadek Posted April 4, 2022 Author Share Posted April 4, 2022 (edited) foreach ($inventories['rgDescriptions'] as $key => $description){ $samik = $description['app_data']; $url[] = "https://api2.prices.tf/prices/".$samik["def_index"]."%3B".$samik["quality"]; } $curl = curl_init($url);curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $headers = array( "accept: application/json", "Authorization: Bearer " .$value. " ",); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); //for debug only!curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $resp = curl_exec($curl);curl_close($curl); //var_dump($resp); I need foreach for the url and then use the data outside of the foreach in curl Edited April 4, 2022 by samcadek Quote Link to comment https://forums.phpfreaks.com/topic/314661-hello-i-need-help-with-getting-this-url-value-into-the-foreach-without-the-var-dump-because-it-causes-a-big-loading-time/#findComment-1594867 Share on other sites More sharing options...
gizmola Posted April 4, 2022 Share Posted April 4, 2022 People will need to see the structure of $resp in order to help you. Also, please use the code button <> to paste your code into your posts. Quote Link to comment https://forums.phpfreaks.com/topic/314661-hello-i-need-help-with-getting-this-url-value-into-the-foreach-without-the-var-dump-because-it-causes-a-big-loading-time/#findComment-1594868 Share on other sites More sharing options...
samcadek Posted April 4, 2022 Author Share Posted April 4, 2022 "{"sku":"730;6","buyHalfScrap":1,"buyKeys":0,"buyKeyHalfScrap":1238,"sellHalfScrap":2,"sellKeys":0,"sellKeyHalfScrap":1240,"createdAt":"2021-10-12T00:51:43.597Z","updatedAt":"2022-04-04T19:01:57.111Z"}" Quote Link to comment https://forums.phpfreaks.com/topic/314661-hello-i-need-help-with-getting-this-url-value-into-the-foreach-without-the-var-dump-because-it-causes-a-big-loading-time/#findComment-1594870 Share on other sites More sharing options...
gizmola Posted April 5, 2022 Share Posted April 5, 2022 I don't see a url in that data. Quote Link to comment https://forums.phpfreaks.com/topic/314661-hello-i-need-help-with-getting-this-url-value-into-the-foreach-without-the-var-dump-because-it-causes-a-big-loading-time/#findComment-1594878 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.