Product id (multisite setup) - php
We are building a script that makes an xml export of orders. In the export, we need to get the EAN code of the product that has been ordered. Currently we use WooCommerce to get the product info, and get the _sku from there.
However, we notice something is going wrong with our multisite setup.
When a product is ordered from site B, we sometimes are unable to get the EAN code of the ordered product, or get a wrong EAN code.
This because if we use our script and ask WooCommerce -> getOrder -> getItems, we get the product id's from site A, not site B. So when we try to get the _sku info from an ordered item, it's looking for the wrong product.
How can we make sure that with our script, it knows what _sku to take when we get our order information so that it doesn't matter which site the order came from, the order information is always correct?
function bol_2020_custom_process_order_manual($order_id) {
global $voorletters;
$order = new WC_Order( $order_id );
// $myuser_id = (int)$order->user_id;
// $user_info = get_userdata($myuser_id);
// $customer = new WC_Customer($order_id);
$items = $order->get_items();
$xml_order_id = $order_id;
$xml_ORDER_DATE = date('Y-m-d');
$xml_DELIVERY_START_DATE = '2017-09-07';
$xml_DELIVERY_END_DATE = '2017-09-08';
$xml_SUPPLIER_NAME = 'DOMAINNAME.nl';
$xml_SUPPLIER_NAME2 = '';
$xml_SUPPLIER_NAME3 = '';
$xml_SUPPLIER_STREET = '**** 71A';
$xml_SUPPLIER_ZIP = '******';
$xml_SUPPLIER_CITY = '********';
$xml_SUPPLIER_COUNTRY = 'NL';
$xml_BUYUR_NAME = get_post_meta($order_id,'_shipping_first_name',true).' '.get_post_meta($order_id,'_shipping_last_name',true);
$xml_BUYUR_NAME2 = get_post_meta($order_id,'_shipping_company',true);
$xml_BUYUR_NAME3 = '';
$xml_BUYUR_STREET = get_post_meta($order_id,'_shipping_address_1',true).' '.get_post_meta($order_id,'_shipping_address_2',true);
$xml_BUYUR_ZIP = get_post_meta($order_id,'_shipping_postcode',true);
$xml_BUYUR_CITY = get_post_meta($order_id,'_shipping_city',true);
$xml_BUYUR_COUNTRY = get_post_meta($order_id,'_shipping_country',true);
$imp = new DOMImplementation;
$dtd = $imp->createDocumentType('ORDER', '', 'openTRANS_ORDER_1_0.dtd');
$dom = $imp->createDocument("", "", $dtd);
$dom->encoding = 'UTF-8';
$root = $dom->appendChild($root = $dom->createElement('ORDER'));
$order_version = $root->appendChild($dom->createAttribute('version'));
$order_version->value = '1.0';
$order_type = $root->appendChild($dom->createAttribute('type'));
$order_type->value = 'standard';
$root->appendChild($client = $dom->createElement('ORDER_HEADER'));
$order_info = $client->appendChild($dom->createElement('ORDER_INFO'));
$order_info->appendChild($ORDER_ID = $order_info->appendChild($dom->createElement('ORDER_ID')));
$ORDER_ID->appendChild($dom->createTextNode($voorletters.$xml_order_id));
$order_info->appendChild($ALT_CUSTOMER_ORDER_ID = $order_info->appendChild($dom->createElement('ALT_CUSTOMER_ORDER_ID')));
$ALT_CUSTOMER_ORDER_ID->appendChild($dom->createTextNode(''));
$order_info->appendChild($ORDER_DATE = $order_info->appendChild($dom->createElement('ORDER_DATE')));
$ORDER_DATE->appendChild($dom->createTextNode($xml_ORDER_DATE));
$DELIVERY_DATE = $order_info->appendChild($order_info->appendChild($dom->createElement('DELIVERY_DATE')));
$DELIVERY_DATE_ATT = $DELIVERY_DATE->appendChild($dom->createAttribute('type'));
$DELIVERY_DATE_ATT->value = 'fixed';
$DELIVERY_START_DATE = $DELIVERY_DATE->appendChild($dom->createElement('DELIVERY_START_DATE'));
$DELIVERY_START_DATE->appendChild($dom->createTextNode($xml_DELIVERY_START_DATE));
$DELIVERY_END_DATE = $DELIVERY_DATE->appendChild($dom->createElement('DELIVERY_END_DATE'));
$DELIVERY_END_DATE->appendChild($dom->createTextNode($xml_DELIVERY_END_DATE));
$ORDER_PARTIES = $order_info->appendChild($order_info->appendChild($dom->createElement('ORDER_PARTIES')));
$BUYER_PARTY = $ORDER_PARTIES->appendChild($dom->createElement('BUYER_PARTY'));
$PARTY_ID = $BUYER_PARTY->appendChild($dom->createElement('PARTY'));
$PARTY_ID_ = $PARTY_ID->appendChild($dom->createElement('PARTY_ID'));
$PARTY_ID__ATT = $PARTY_ID_->appendChild($dom->createAttribute('type'));
$PARTY_ID__ATT->value = 'ILN';
//$PARTY_ID_->appendChild($dom->createTextNode('4317784032988'));
$PARTY_ID_->appendChild($dom->createTextNode('4317784044110'));
$SUPPLIER_PARTY = $ORDER_PARTIES->appendChild($dom->createElement('SUPPLIER_PARTY'));
$PARTY_ID = $SUPPLIER_PARTY->appendChild($dom->createElement('PARTY'));
$PARTY_ID_ = $PARTY_ID->appendChild($dom->createElement('PARTY_ID'));
$PARTY_ID__ATT = $PARTY_ID_->appendChild($dom->createAttribute('type'));
$PARTY_ID__ATT->value = 'ILN';
$PARTY_ID_->appendChild($dom->createTextNode('4317784000000'));
$SHIPMENT_PARTIES = $ORDER_PARTIES->appendChild($dom->createElement('SHIPMENT_PARTIES'));
$DELIVERY_PARTY = $SHIPMENT_PARTIES->appendChild($dom->createElement('DELIVERY_PARTY'));
$PARTY = $DELIVERY_PARTY->appendChild($dom->createElement('PARTY'));
$PARTY_ID = $PARTY->appendChild($dom->createElement('PARTY_ID'));
$PARTY_ID_ATT = $PARTY_ID->appendChild($dom->createAttribute('type'));
$PARTY_ID_ATT->value = 'supplier_specific';
$PARTY_ID->appendChild($dom->createTextNode(''));
$ADDRESS = $PARTY->appendChild($dom->createElement('ADDRESS'));
$NAME = $ADDRESS->appendChild($dom->createElement('NAME'));
$NAME->appendChild($dom->createTextNode($xml_SUPPLIER_NAME));
$NAME2 = $ADDRESS->appendChild($dom->createElement('NAME2'));
$NAME2->appendChild($dom->createTextNode($xml_SUPPLIER_NAME2));
$NAME3 = $ADDRESS->appendChild($dom->createElement('NAME3'));
$NAME3->appendChild($dom->createTextNode($xml_SUPPLIER_NAME3));
$STREET = $ADDRESS->appendChild($dom->createElement('STREET'));
$STREET->appendChild($dom->createTextNode($xml_SUPPLIER_STREET));
$ZIP = $ADDRESS->appendChild($dom->createElement('ZIP'));
$ZIP->appendChild($dom->createTextNode($xml_SUPPLIER_ZIP));
$CITY = $ADDRESS->appendChild($dom->createElement('CITY'));
$CITY->appendChild($dom->createTextNode($xml_SUPPLIER_CITY));
$COUNTRY = $ADDRESS->appendChild($dom->createElement('COUNTRY'));
$COUNTRY->appendChild($dom->createTextNode($xml_SUPPLIER_COUNTRY));
$FINAL_DELIVERY_PARTY = $SHIPMENT_PARTIES->appendChild($dom->createElement('FINAL_DELIVERY_PARTY'));
$PARTY = $FINAL_DELIVERY_PARTY->appendChild($dom->createElement('PARTY'));
$PARTY_ID = $PARTY->appendChild($dom->createElement('PARTY_ID'));
$PARTY_ID_ATT = $PARTY_ID->appendChild($dom->createAttribute('type'));
$PARTY_ID_ATT->value = 'buyer_specific';
$PARTY_ID->appendChild($dom->createTextNode(''));
$ADDRESS = $PARTY->appendChild($dom->createElement('ADDRESS'));
$NAME = $ADDRESS->appendChild($dom->createElement('NAME'));
$NAME->appendChild($dom->createTextNode($xml_BUYUR_NAME));
$NAME2 = $ADDRESS->appendChild($dom->createElement('NAME2'));
$NAME2->appendChild($dom->createTextNode($xml_BUYUR_NAME2));
$NAME3 = $ADDRESS->appendChild($dom->createElement('NAME3'));
$NAME3->appendChild($dom->createTextNode($xml_BUYUR_NAME3));
$STREET = $ADDRESS->appendChild($dom->createElement('STREET'));
$STREET->appendChild($dom->createTextNode($xml_BUYUR_STREET));
$ZIP = $ADDRESS->appendChild($dom->createElement('ZIP'));
$ZIP->appendChild($dom->createTextNode($xml_BUYUR_ZIP));
$CITY = $ADDRESS->appendChild($dom->createElement('CITY'));
$CITY->appendChild($dom->createTextNode($xml_BUYUR_CITY));
$COUNTRY = $ADDRESS->appendChild($dom->createElement('COUNTRY'));
$COUNTRY->appendChild($dom->createTextNode($xml_BUYUR_COUNTRY));
$PARTIAL_SHIPMENT_ALLOWED = $order_info->appendChild($order_info->appendChild($dom->createElement('PARTIAL_SHIPMENT_ALLOWED')));
$PARTIAL_SHIPMENT_ALLOWED->appendChild($dom->createTextNode('False'));
$TRANSPORT = $order_info->appendChild($order_info->appendChild($dom->createElement('TRANSPORT')));
$INCOTERM = $TRANSPORT->appendChild($dom->createElement('INCOTERM'));
$INCOTERM->appendChild($dom->createTextNode(''));
$LOCATION = $TRANSPORT->appendChild($dom->createElement('LOCATION'));
$LOCATION->appendChild($dom->createTextNode('EKD'));
$TRANSPORT_REMARK = $TRANSPORT->appendChild($dom->createElement('TRANSPORT_REMARK'));
$TRANSPORT_REMARK->appendChild($dom->createTextNode('10'));
$REMARK_GENERAL = $order_info->appendChild($order_info->appendChild($dom->createElement('REMARK')));
$REMARK_GENERAL_ = $REMARK_GENERAL->appendChild($dom->createAttribute('type'));
$REMARK_GENERAL_->value = 'general';
$REMARK_GENERAL->appendChild($dom->createTextNode('SUPERHANDIG.NL IS HÉT ADRES VOOR PROF. GEREEDSCHAP EN ACCESSOIRES!'));
$REMARK_ORDER = $order_info->appendChild($order_info->appendChild($dom->createElement('REMARK')));
$REMARK_ORDER_ = $REMARK_ORDER->appendChild($dom->createAttribute('type'));
$REMARK_ORDER_->value = 'order';
$REMARK_ORDER->appendChild($dom->createTextNode($voorletters.$xml_order_id));
$ORDER_ITEM_LIST = $root->appendChild($client = $dom->createElement('ORDER_ITEM_LIST'));
$i = 0;
foreach ($items as $item) {
$ean = get_post_meta($item['product_id'], '_sku'); // for single products
$qty = $item['qty'];
if(empty($ean[0])){
$ean = get_post_meta($item['variation_id'], '_sku'); // for variable products
}
$i++;
$ORDER_ITEM = $ORDER_ITEM_LIST->appendChild($dom->createElement('ORDER_ITEM'));
$LINE_ITEM_ID = $ORDER_ITEM->appendChild($dom->createElement('LINE_ITEM_ID'));
$LINE_ITEM_ID->appendChild($dom->createTextNode($i));
$ARTICLE_ID = $ORDER_ITEM->appendChild($dom->createElement('ARTICLE_ID'));
$SUPPLIER_AID = $ARTICLE_ID->appendChild($dom->createElement('SUPPLIER_AID'));
$SUPPLIER_AID->appendChild($dom->createTextNode(''));
$INTERNATIONAL_AID = $ARTICLE_ID->appendChild($dom->createElement('INTERNATIONAL_AID'));
$INTERNATIONAL_AID_ = $INTERNATIONAL_AID->appendChild($dom->createAttribute('type'));
$INTERNATIONAL_AID_->value = 'EAN';
$INTERNATIONAL_AID->appendChild($dom->createTextNode($ean[0]));
$BUYER_AID = $ARTICLE_ID->appendChild($dom->createElement('BUYER_AID'));
$BUYER_AID_ = $BUYER_AID->appendChild($dom->createAttribute('type'));
$BUYER_AID_->value = 'BP';
$BUYER_AID->appendChild($dom->createTextNode(''));
$BUYER_AID = $ARTICLE_ID->appendChild($dom->createElement('BUYER_AID'));
$BUYER_AID_ = $BUYER_AID->appendChild($dom->createAttribute('type'));
$BUYER_AID_->value = 'IN';
$BUYER_AID->appendChild($dom->createTextNode(''));
$DESCRIPTION_SHORT = $ARTICLE_ID->appendChild($dom->createElement('DESCRIPTION_SHORT'));
$DESCRIPTION_SHORT->appendChild($dom->createTextNode(''));
$QUANTITY = $ORDER_ITEM->appendChild($dom->createElement('QUANTITY'));
$QUANTITY->appendChild($dom->createTextNode($qty));
$ORDER_UNIT = $ORDER_ITEM->appendChild($dom->createElement('ORDER_UNIT'));
$ORDER_UNIT->appendChild($dom->createTextNode('C62'));
}
$ORDER_SUMMARY = $root->appendChild($client = $dom->createElement('ORDER_SUMMARY'));
$TOTAL_ITEM_NUM = $ORDER_SUMMARY->appendChild($dom->createElement('TOTAL_ITEM_NUM'));
$TOTAL_ITEM_NUM->appendChild($dom->createTextNode($i));
$dom->formatOutput = true;
$dom->save($_SERVER['DOCUMENT_ROOT'].'/ede_orders/xml/'.$voorletters.$xml_order_id.'.xml');
}
https://gist.github.com/webstylecenter/2491735366a70d82336512e0d0cc4e8f
Related
Slow PHP Script YoutubeAPI
This script have very long loading times. If i refresh my page it takes 3.5 seconds to load up this script. What can causes this? <?php //Instagram Getter // use this instagram access token generator http://instagram.pixelunion.net/ $access_token=""; $photo_count=9; $json_instalink="https://api.instagram.com/v1/users/self/media/recent/?access_token=$access_token&count=$photo_count"; $jsoninsta = file_get_contents($json_instalink); $objinsta = json_decode($jsoninsta); //Link zu den Bildern $imagelink1 = $objinsta->data[0]->link; $imagelink2 = $objinsta->data[1]->link; $imagelink3 = $objinsta->data[2]->link; $imagelink4 = $objinsta->data[3]->link; $imagelink5 = $objinsta->data[4]->link; $imagelink6 = $objinsta->data[5]->link; $imagelink7 = $objinsta->data[6]->link; $imagelink8 = $objinsta->data[7]->link; $imagelink9 = $objinsta->data[8]->link; //Das Bild an sich $profilelink1 = $objinsta->data[0]->images->standard_resolution->url; $profilelink2 = $objinsta->data[1]->images->standard_resolution->url; $profilelink3 = $objinsta->data[2]->images->standard_resolution->url; $profilelink4 = $objinsta->data[3]->images->standard_resolution->url; $profilelink5 = $objinsta->data[4]->images->standard_resolution->url; $profilelink6 = $objinsta->data[5]->images->standard_resolution->url; $profilelink7 = $objinsta->data[6]->images->standard_resolution->url; $profilelink8 = $objinsta->data[7]->images->standard_resolution->url; $profilelink9 = $objinsta->data[8]->images->standard_resolution->url; //Channel and API Key $channel_id = ''; $api_key = ''; //Channel Statistics $json_statsurl="https://www.googleapis.com/youtube/v3/channels?part=statistics&id=$channel_id&key=$api_key"; $jsonstats = file_get_contents($json_statsurl); $listFromYouTube=json_decode($jsonstats); $subscriberCount = $listFromYouTube->items[0]->statistics->subscriberCount; //Last Video $json_lastvidurl="https://www.googleapis.com/youtube/v3/search?key=$api_key&channelId=$channel_id&part=id&order=date&maxResults=1"; $jsonlastvid = file_get_contents($json_lastvidurl); $listFromYouTube=json_decode($jsonlastvid); $lastvidid = $listFromYouTube->items[0]->id->videoId; //Last Video Views $json_lastvidstatsurl="https://www.googleapis.com/youtube/v3/videos?part=statistics&id=$lastvidid&key=$api_key"; $jsonlastvidstats = file_get_contents($json_lastvidstatsurl); $listFromYouTube=json_decode($jsonlastvidstats); $lastvidviews = $listFromYouTube->items[0]->statistics->viewCount; //Last Video Published Date $json_lastvidinfourl="https://www.googleapis.com/youtube/v3/videos?part=snippet&id=$lastvidid&key=$api_key"; $jsonlastvidinfo = file_get_contents($json_lastvidinfourl); $listFromYouTube=json_decode($jsonlastvidinfo); $lastvidtitle = $listFromYouTube->items[0]->snippet->title; $lastvidpublished = $listFromYouTube->items[0]->snippet->publishedAt; //Playlist Videos 9 $json_9vidurl="https://www.googleapis.com/youtube/v3/search?key=$api_key&channelId=$channel_id&part=snippet,id&order=date&maxResults=10"; $json9vid = file_get_contents($json_9vidurl); $listFromYouTube=json_decode($json9vid); $vid0=$listFromYouTube->items[1]->id->videoId; $vid1=$listFromYouTube->items[2]->id->videoId; $vid2=$listFromYouTube->items[3]->id->videoId; $vid3=$listFromYouTube->items[4]->id->videoId; $vid4=$listFromYouTube->items[5]->id->videoId; $vid5=$listFromYouTube->items[6]->id->videoId; $vid6=$listFromYouTube->items[7]->id->videoId; $vid7=$listFromYouTube->items[8]->id->videoId; $vid8=$listFromYouTube->items[9]->id->videoId; $watchlink="http://undercover-gaming.de/youtube/video/"; // TITLE PART $vid0t=$listFromYouTube->items[1]->snippet->title; $vid1t=$listFromYouTube->items[2]->snippet->title; $vid2t=$listFromYouTube->items[3]->snippet->title; $vid3t=$listFromYouTube->items[4]->snippet->title; $vid4t=$listFromYouTube->items[5]->snippet->title; $vid5t=$listFromYouTube->items[6]->snippet->title; $vid6t=$listFromYouTube->items[7]->snippet->title; $vid7t=$listFromYouTube->items[8]->snippet->title; $vid8t=$listFromYouTube->items[9]->snippet->title; // PUBLISH PART $json_vid0url="https://www.googleapis.com/youtube/v3/videos?part=snippet&id=$vid0&key=$api_key"; $jsonlastvid0 = file_get_contents($json_vid0url); $listFromYouTube=json_decode($jsonlastvid0); $vid0published = $listFromYouTube->items[0]->snippet->publishedAt; $json_vid1url="https://www.googleapis.com/youtube/v3/videos?part=snippet&id=$vid1&key=$api_key"; $jsonlastvid1 = file_get_contents($json_vid1url); $listFromYouTube=json_decode($jsonlastvid1); $vid1published = $listFromYouTube->items[0]->snippet->publishedAt; $json_vid2url="https://www.googleapis.com/youtube/v3/videos?part=snippet&id=$vid2&key=$api_key"; $jsonlastvid2 = file_get_contents($json_vid2url); $listFromYouTube=json_decode($jsonlastvid2); $vid2published = $listFromYouTube->items[0]->snippet->publishedAt; $json_vid3url="https://www.googleapis.com/youtube/v3/videos?part=snippet&id=$vid3&key=$api_key"; $jsonlastvid3 = file_get_contents($json_vid3url); $listFromYouTube=json_decode($jsonlastvid3); $vid3published = $listFromYouTube->items[0]->snippet->publishedAt; $json_vid4url="https://www.googleapis.com/youtube/v3/videos?part=snippet&id=$vid4&key=$api_key"; $jsonlastvid4 = file_get_contents($json_vid4url); $listFromYouTube=json_decode($jsonlastvid4); $vid4published = $listFromYouTube->items[0]->snippet->publishedAt; $json_vid5url="https://www.googleapis.com/youtube/v3/videos?part=snippet&id=$vid5&key=$api_key"; $jsonlastvid5 = file_get_contents($json_vid5url); $listFromYouTube=json_decode($jsonlastvid5); $vid5published = $listFromYouTube->items[0]->snippet->publishedAt; $json_vid6url="https://www.googleapis.com/youtube/v3/videos?part=snippet&id=$vid6&key=$api_key"; $jsonlastvid6 = file_get_contents($json_vid6url); $listFromYouTube=json_decode($jsonlastvid6); $vid6published = $listFromYouTube->items[0]->snippet->publishedAt; $json_vid7url="https://www.googleapis.com/youtube/v3/videos?part=snippet&id=$vid7&key=$api_key"; $jsonlastvid7 = file_get_contents($json_vid7url); $listFromYouTube=json_decode($jsonlastvid7); $vid7published = $listFromYouTube->items[0]->snippet->publishedAt; $json_vid8url="https://www.googleapis.com/youtube/v3/videos?part=snippet&id=$vid8&key=$api_key"; $jsonlastvid8 = file_get_contents($json_vid8url); $listFromYouTube=json_decode($jsonlastvid8); $vid8published = $listFromYouTube->items[0]->snippet->publishedAt; //VIEW PART 0-8 $json_viewgetter="https://www.googleapis.com/youtube/v3/videos?part=statistics&id=$vid0&key=$api_key"; $jsonplaylistgetter = file_get_contents($json_viewgetter); $listFromYouTube=json_decode($jsonplaylistgetter); $vid0views=$listFromYouTube->items[0]->statistics->viewCount; $json_viewgetter1="https://www.googleapis.com/youtube/v3/videos?part=statistics&id=$vid1&key=$api_key"; $jsonplaylistgetter1 = file_get_contents($json_viewgetter1); $listFromYouTube=json_decode($jsonplaylistgetter1); $vid1views=$listFromYouTube->items[0]->statistics->viewCount; $json_viewgetter2="https://www.googleapis.com/youtube/v3/videos?part=statistics&id=$vid2&key=$api_key"; $jsonplaylistgetter2 = file_get_contents($json_viewgetter2); $listFromYouTube=json_decode($jsonplaylistgetter2); $vid2views=$listFromYouTube->items[0]->statistics->viewCount; $json_viewgetter3="https://www.googleapis.com/youtube/v3/videos?part=statistics&id=$vid3&key=$api_key"; $jsonplaylistgetter3 = file_get_contents($json_viewgetter3); $listFromYouTube=json_decode($jsonplaylistgetter); $vid3views=$listFromYouTube->items[0]->statistics->viewCount; $json_viewgetter4="https://www.googleapis.com/youtube/v3/videos?part=statistics&id=$vid4&key=$api_key"; $jsonplaylistgetter4 = file_get_contents($json_viewgetter4); $listFromYouTube=json_decode($jsonplaylistgetter4); $vid4views=$listFromYouTube->items[0]->statistics->viewCount; $json_viewgetter5="https://www.googleapis.com/youtube/v3/videos?part=statistics&id=$vid5&key=$api_key"; $jsonplaylistgetter5 = file_get_contents($json_viewgetter5); $listFromYouTube=json_decode($jsonplaylistgetter5); $vid5views=$listFromYouTube->items[0]->statistics->viewCount; $json_viewgetter6="https://www.googleapis.com/youtube/v3/videos?part=statistics&id=$vid6&key=$api_key"; $jsonplaylistgetter6 = file_get_contents($json_viewgetter6); $listFromYouTube=json_decode($jsonplaylistgetter6); $vid6views=$listFromYouTube->items[0]->statistics->viewCount; $json_viewgetter7="https://www.googleapis.com/youtube/v3/videos?part=statistics&id=$vid7&key=$api_key"; $jsonplaylistgetter7 = file_get_contents($json_viewgetter7); $listFromYouTube=json_decode($jsonplaylistgetter7); $vid7views=$listFromYouTube->items[0]->statistics->viewCount; $json_viewgetter8="https://www.googleapis.com/youtube/v3/videos?part=statistics&id=$vid8&key=$api_key"; $jsonplaylistgetter8 = file_get_contents($json_viewgetter8); $listFromYouTube=json_decode($jsonplaylistgetter8); $vid8views=$listFromYouTube->items[0]->statistics->viewCount; //Last Video Thumbnails $images = json_decode(file_get_contents("http://gdata.youtube.com/feeds/api/videos/".$lastvidid."?v=2&alt=json"), true); $images = $images['entry']['media$group']['media$thumbnail']; $image = $images[count($images)-4]['url']; $maxurl = "http://i.ytimg.com/vi/".$lastvidid."/maxresdefault.jpg"; $vidurl0 = "http://i.ytimg.com/vi/".$vid0."/maxresdefault.jpg"; $vidurl1 = "http://i.ytimg.com/vi/".$vid1."/maxresdefault.jpg"; $vidurl2 = "http://i.ytimg.com/vi/".$vid2."/maxresdefault.jpg"; $vidurl3 = "http://i.ytimg.com/vi/".$vid3."/maxresdefault.jpg"; $vidurl4 = "http://i.ytimg.com/vi/".$vid4."/maxresdefault.jpg"; $vidurl5 = "http://i.ytimg.com/vi/".$vid5."/maxresdefault.jpg"; $vidurl6 = "http://i.ytimg.com/vi/".$vid6."/maxresdefault.jpg"; $vidurl7 = "http://i.ytimg.com/vi/".$vid7."/maxresdefault.jpg"; $vidurl8 = "http://i.ytimg.com/vi/".$vid8."/maxresdefault.jpg"; $max = get_headers($maxurl); if (substr($max[0], 9, 3) !== '404') { $image = $maxurl; } ?>
I changed my code a little bet and got not that much file_get_contents. But i found out that the Instagram API is really slow. So if i integrate the instagram API my page loaded really slow. If i use Jquery Code it works fast but, everyone can look into the code and see the script brackets and thats what i dont want. <?php //Instagram Getter // use this instagram access token generator http://instagram.pixelunion.net/ $access_token=""; $photo_count=9; $json_instalink="https://api.instagram.com/v1/users/self/media/recent/?access_token=$access_token&count=$photo_count"; $jsoninsta = file_get_contents($json_instalink); $objinsta = json_decode($jsoninsta); //Link zu den Bildern $imagelink1 = $objinsta->data[0]->link; $imagelink2 = $objinsta->data[1]->link; $imagelink3 = $objinsta->data[2]->link; $imagelink4 = $objinsta->data[3]->link; $imagelink5 = $objinsta->data[4]->link; $imagelink6 = $objinsta->data[5]->link; $imagelink7 = $objinsta->data[6]->link; $imagelink8 = $objinsta->data[7]->link; $imagelink9 = $objinsta->data[8]->link; //Das Bild an sich $profilelink1 = $objinsta->data[0]->images->standard_resolution->url; $profilelink2 = $objinsta->data[1]->images->standard_resolution->url; $profilelink3 = $objinsta->data[2]->images->standard_resolution->url; $profilelink4 = $objinsta->data[3]->images->standard_resolution->url; $profilelink5 = $objinsta->data[4]->images->standard_resolution->url; $profilelink6 = $objinsta->data[5]->images->standard_resolution->url; $profilelink7 = $objinsta->data[6]->images->standard_resolution->url; $profilelink8 = $objinsta->data[7]->images->standard_resolution->url; $profilelink9 = $objinsta->data[8]->images->standard_resolution->url; //Channel and API Key $channel_id = ''; $api_key = ''; //Channel Statistics $json_statsurl="https://www.googleapis.com/youtube/v3/channels?part=statistics&id=$channel_id&key=$api_key"; $jsonstats = file_get_contents($json_statsurl); $listFromYouTube=json_decode($jsonstats); $subscriberCount = $listFromYouTube->items[0]->statistics->subscriberCount; //Last Video ID/Title/Published/Thumbnails $json_lastvidurl="https://www.googleapis.com/youtube/v3/search?key=$api_key&channelId=$channel_id&part=snippet,id&order=date&maxResults=10"; $jsonlastvid = file_get_contents($json_lastvidurl); $listFromYouTube=json_decode($jsonlastvid); $lastvidid = $listFromYouTube->items[0]->id->videoId; $lastvidtitle = $listFromYouTube->items[0]->snippet->title; $lastvidpublished = $listFromYouTube->items[0]->snippet->publishedAt; $maxurl = "http://i.ytimg.com/vi/".$lastvidid."/maxresdefault.jpg"; //Playlist Videos 9 ID/Title/Published/Thumbnails $vid0=$listFromYouTube->items[1]->id->videoId; $vid1=$listFromYouTube->items[2]->id->videoId; $vid2=$listFromYouTube->items[3]->id->videoId; $vid3=$listFromYouTube->items[4]->id->videoId; $vid4=$listFromYouTube->items[5]->id->videoId; $vid5=$listFromYouTube->items[6]->id->videoId; $vid6=$listFromYouTube->items[7]->id->videoId; $vid7=$listFromYouTube->items[8]->id->videoId; $vid8=$listFromYouTube->items[9]->id->videoId; $vid0t=$listFromYouTube->items[1]->snippet->title; $vid1t=$listFromYouTube->items[2]->snippet->title; $vid2t=$listFromYouTube->items[3]->snippet->title; $vid3t=$listFromYouTube->items[4]->snippet->title; $vid4t=$listFromYouTube->items[5]->snippet->title; $vid5t=$listFromYouTube->items[6]->snippet->title; $vid6t=$listFromYouTube->items[7]->snippet->title; $vid7t=$listFromYouTube->items[8]->snippet->title; $vid8t=$listFromYouTube->items[9]->snippet->title; $vid0published = $listFromYouTube->items[1]->snippet->publishedAt; $vid1published = $listFromYouTube->items[2]->snippet->publishedAt; $vid2published = $listFromYouTube->items[3]->snippet->publishedAt; $vid3published = $listFromYouTube->items[4]->snippet->publishedAt; $vid4published = $listFromYouTube->items[5]->snippet->publishedAt; $vid5published = $listFromYouTube->items[6]->snippet->publishedAt; $vid6published = $listFromYouTube->items[7]->snippet->publishedAt; $vid7published = $listFromYouTube->items[8]->snippet->publishedAt; $vid8published = $listFromYouTube->items[9]->snippet->publishedAt; $vidurl0 = "http://i.ytimg.com/vi/".$vid0."/maxresdefault.jpg"; $vidurl1 = "http://i.ytimg.com/vi/".$vid1."/maxresdefault.jpg"; $vidurl2 = "http://i.ytimg.com/vi/".$vid2."/maxresdefault.jpg"; $vidurl3 = "http://i.ytimg.com/vi/".$vid3."/maxresdefault.jpg"; $vidurl4 = "http://i.ytimg.com/vi/".$vid4."/maxresdefault.jpg"; $vidurl5 = "http://i.ytimg.com/vi/".$vid5."/maxresdefault.jpg"; $vidurl6 = "http://i.ytimg.com/vi/".$vid6."/maxresdefault.jpg"; $vidurl7 = "http://i.ytimg.com/vi/".$vid7."/maxresdefault.jpg"; $vidurl8 = "http://i.ytimg.com/vi/".$vid8."/maxresdefault.jpg"; //Last Video Views $json_lastvidstatsurl="https://www.googleapis.com/youtube/v3/videos?part=statistics&id=$lastvidid,$vid0,$vid1,$vid2,$vid3,$vid4,$vid5,$vid6,$vid7,$vid8&key=$api_key"; $jsonlastvidstats = file_get_contents($json_lastvidstatsurl); $listFromYouTube=json_decode($jsonlastvidstats); $lastvidviews = $listFromYouTube->items[0]->statistics->viewCount; $vid0views = $listFromYouTube->items[1]->statistics->viewCount; $vid1views = $listFromYouTube->items[2]->statistics->viewCount; $vid2views = $listFromYouTube->items[3]->statistics->viewCount; $vid3views = $listFromYouTube->items[4]->statistics->viewCount; $vid4views = $listFromYouTube->items[5]->statistics->viewCount; $vid5views = $listFromYouTube->items[6]->statistics->viewCount; $vid6views = $listFromYouTube->items[7]->statistics->viewCount; $vid7views = $listFromYouTube->items[8]->statistics->viewCount; $vid8views = $listFromYouTube->items[9]->statistics->viewCount; //Watchlink $watchlink="http://undercover-gaming.de/youtube/video/"; ?>
What is more efficient? Connecting to the DB or having a couple hundred rows in an array?
I'm trying to get the calling code and the country name of my visitors. Previously, I had a connection to the DB to get the calling code and country name that matches the one we got from CloudFlare, using $_SERVER["HTTP_CF_IPCOUNTRY"]; and $country_code=$_SERVER["HTTP_CF_IPCOUNTRY"]; $stmt = $pdo->query('SELECT short_name, calling_code from country WHERE iso2 LIKE "'.$country_code.'"'); $country = $stmt->fetch(); However, when traffic gets heavy, having many connections to the DB can be problematic. So I defined this array: $countries = array(); $countries['AF'] = array("code"=>"AF","short_name"=>"Afghanistan","calling_code"=>"93"); $countries['AL'] = array("code"=>"AL","short_name"=>"Albania","calling_code"=>"355"); $countries['DZ'] = array("code"=>"DZ","short_name"=>"Algeria","calling_code"=>"213"); $countries['AS'] = array("code"=>"AS","short_name"=>"American Samoa","calling_code"=>"1"); $countries['AD'] = array("code"=>"AD","short_name"=>"Andorra","calling_code"=>"376"); $countries['AO'] = array("code"=>"AO","short_name"=>"Angola","calling_code"=>"244"); $countries['AI'] = array("code"=>"AI","short_name"=>"Anguilla","calling_code"=>"1"); $countries['AG'] = array("code"=>"AG","short_name"=>"Antigua","calling_code"=>"1"); $countries['AR'] = array("code"=>"AR","short_name"=>"Argentina","calling_code"=>"54"); $countries['AM'] = array("code"=>"AM","short_name"=>"Armenia","calling_code"=>"374"); $countries['AW'] = array("code"=>"AW","short_name"=>"Aruba","calling_code"=>"297"); $countries['AU'] = array("code"=>"AU","short_name"=>"Australia","calling_code"=>"61"); $countries['AT'] = array("code"=>"AT","short_name"=>"Austria","calling_code"=>"43"); $countries['AZ'] = array("code"=>"AZ","short_name"=>"Azerbaijan","calling_code"=>"994"); $countries['BH'] = array("code"=>"BH","short_name"=>"Bahrain","calling_code"=>"973"); $countries['BD'] = array("code"=>"BD","short_name"=>"Bangladesh","calling_code"=>"880"); $countries['BB'] = array("code"=>"BB","short_name"=>"Barbados","calling_code"=>"1"); $countries['BY'] = array("code"=>"BY","short_name"=>"Belarus","calling_code"=>"375"); $countries['BE'] = array("code"=>"BE","short_name"=>"Belgium","calling_code"=>"32"); $countries['BZ'] = array("code"=>"BZ","short_name"=>"Belize","calling_code"=>"501"); $countries['BJ'] = array("code"=>"BJ","short_name"=>"Benin","calling_code"=>"229"); $countries['BM'] = array("code"=>"BM","short_name"=>"Bermuda","calling_code"=>"1"); $countries['BT'] = array("code"=>"BT","short_name"=>"Bhutan","calling_code"=>"975"); $countries['BO'] = array("code"=>"BO","short_name"=>"Bolivia","calling_code"=>"591"); $countries['BA'] = array("code"=>"BA","short_name"=>"Bosnia and Herzegovina","calling_code"=>"387"); $countries['BW'] = array("code"=>"BW","short_name"=>"Botswana","calling_code"=>"267"); $countries['BR'] = array("code"=>"BR","short_name"=>"Brazil","calling_code"=>"55"); $countries['IO'] = array("code"=>"IO","short_name"=>"British Indian Ocean Territory","calling_code"=>"246"); $countries['VG'] = array("code"=>"VG","short_name"=>"British Virgin Islands","calling_code"=>"1"); $countries['BN'] = array("code"=>"BN","short_name"=>"Brunei","calling_code"=>"673"); $countries['BG'] = array("code"=>"BG","short_name"=>"Bulgaria","calling_code"=>"359"); $countries['BF'] = array("code"=>"BF","short_name"=>"Burkina Faso","calling_code"=>"226"); $countries['MM'] = array("code"=>"MM","short_name"=>"Burma Myanmar" ,"calling_code"=>"95"); $countries['BI'] = array("code"=>"BI","short_name"=>"Burundi","calling_code"=>"257"); $countries['KH'] = array("code"=>"KH","short_name"=>"Cambodia","calling_code"=>"855"); $countries['CM'] = array("code"=>"CM","short_name"=>"Cameroon","calling_code"=>"237"); $countries['CA'] = array("code"=>"CA","short_name"=>"Canada","calling_code"=>"1"); $countries['CV'] = array("code"=>"CV","short_name"=>"Cape Verde","calling_code"=>"238"); $countries['KY'] = array("code"=>"KY","short_name"=>"Cayman Islands","calling_code"=>"1"); $countries['CF'] = array("code"=>"CF","short_name"=>"Central African Republic","calling_code"=>"236"); $countries['TD'] = array("code"=>"TD","short_name"=>"Chad","calling_code"=>"235"); $countries['CL'] = array("code"=>"CL","short_name"=>"Chile","calling_code"=>"56"); $countries['CN'] = array("code"=>"CN","short_name"=>"China","calling_code"=>"86"); $countries['CO'] = array("code"=>"CO","short_name"=>"Colombia","calling_code"=>"57"); $countries['KM'] = array("code"=>"KM","short_name"=>"Comoros","calling_code"=>"269"); $countries['CK'] = array("code"=>"CK","short_name"=>"Cook Islands","calling_code"=>"682"); $countries['CR'] = array("code"=>"CR","short_name"=>"Costa Rica","calling_code"=>"506"); $countries['CI'] = array("code"=>"CI","short_name"=>"Côte d'Ivoire" ,"calling_code"=>"225"); $countries['HR'] = array("code"=>"HR","short_name"=>"Croatia","calling_code"=>"385"); $countries['CU'] = array("code"=>"CU","short_name"=>"Cuba","calling_code"=>"53"); $countries['CY'] = array("code"=>"CY","short_name"=>"Cyprus","calling_code"=>"357"); $countries['CZ'] = array("code"=>"CZ","short_name"=>"Czech Republic","calling_code"=>"420"); $countries['CD'] = array("code"=>"CD","short_name"=>"Democratic Republic of Congo","calling_code"=>"243"); $countries['DK'] = array("code"=>"DK","short_name"=>"Denmark","calling_code"=>"45"); $countries['DJ'] = array("code"=>"DJ","short_name"=>"Djibouti","calling_code"=>"253"); $countries['DM'] = array("code"=>"DM","short_name"=>"Dominica","calling_code"=>"1"); $countries['DO'] = array("code"=>"DO","short_name"=>"Dominican Republic","calling_code"=>"1"); $countries['EC'] = array("code"=>"EC","short_name"=>"Ecuador","calling_code"=>"593"); $countries['EG'] = array("code"=>"EG","short_name"=>"Egypt","calling_code"=>"20"); $countries['SV'] = array("code"=>"SV","short_name"=>"El Salvador","calling_code"=>"503"); $countries['GQ'] = array("code"=>"GQ","short_name"=>"Equatorial Guinea","calling_code"=>"240"); $countries['ER'] = array("code"=>"ER","short_name"=>"Eritrea","calling_code"=>"291"); $countries['EE'] = array("code"=>"EE","short_name"=>"Estonia","calling_code"=>"372"); $countries['ET'] = array("code"=>"ET","short_name"=>"Ethiopia","calling_code"=>"251"); $countries['FK'] = array("code"=>"FK","short_name"=>"Falkland Islands","calling_code"=>"500"); $countries['FO'] = array("code"=>"FO","short_name"=>"Faroe Islands","calling_code"=>"298"); $countries['FM'] = array("code"=>"FM","short_name"=>"Federated States of Micronesia","calling_code"=>"691"); $countries['FJ'] = array("code"=>"FJ","short_name"=>"Fiji","calling_code"=>"679"); $countries['FI'] = array("code"=>"FI","short_name"=>"Finland","calling_code"=>"358"); $countries['FR'] = array("code"=>"FR","short_name"=>"France","calling_code"=>"33"); $countries['GF'] = array("code"=>"GF","short_name"=>"French Guiana","calling_code"=>"594"); $countries['PF'] = array("code"=>"PF","short_name"=>"French Polynesia","calling_code"=>"689"); $countries['GA'] = array("code"=>"GA","short_name"=>"Gabon","calling_code"=>"241"); $countries['GE'] = array("code"=>"GE","short_name"=>"Georgia","calling_code"=>"995"); $countries['DE'] = array("code"=>"DE","short_name"=>"Germany","calling_code"=>"49"); $countries['GH'] = array("code"=>"GH","short_name"=>"Ghana","calling_code"=>"233"); $countries['GI'] = array("code"=>"GI","short_name"=>"Gibraltar","calling_code"=>"350"); $countries['GR'] = array("code"=>"GR","short_name"=>"Greece","calling_code"=>"30"); $countries['GL'] = array("code"=>"GL","short_name"=>"Greenland","calling_code"=>"299"); $countries['GD'] = array("code"=>"GD","short_name"=>"Grenada","calling_code"=>"1"); $countries['GP'] = array("code"=>"GP","short_name"=>"Guadeloupe","calling_code"=>"590"); $countries['GU'] = array("code"=>"GU","short_name"=>"Guam","calling_code"=>"1"); $countries['GT'] = array("code"=>"GT","short_name"=>"Guatemala","calling_code"=>"502"); $countries['GN'] = array("code"=>"GN","short_name"=>"Guinea","calling_code"=>"224"); $countries['GW'] = array("code"=>"GW","short_name"=>"Guinea-Bissau","calling_code"=>"245"); $countries['GY'] = array("code"=>"GY","short_name"=>"Guyana","calling_code"=>"592"); $countries['HT'] = array("code"=>"HT","short_name"=>"Haiti","calling_code"=>"509"); $countries['HN'] = array("code"=>"HN","short_name"=>"Honduras","calling_code"=>"504"); $countries['HK'] = array("code"=>"HK","short_name"=>"Hong Kong","calling_code"=>"852"); $countries['HU'] = array("code"=>"HU","short_name"=>"Hungary","calling_code"=>"36"); $countries['IS'] = array("code"=>"IS","short_name"=>"Iceland","calling_code"=>"354"); $countries['IN'] = array("code"=>"IN","short_name"=>"India","calling_code"=>"91"); $countries['ID'] = array("code"=>"ID","short_name"=>"Indonesia","calling_code"=>"62"); $countries['IR'] = array("code"=>"IR","short_name"=>"Iran","calling_code"=>"98"); $countries['IQ'] = array("code"=>"IQ","short_name"=>"Iraq","calling_code"=>"964"); $countries['IE'] = array("code"=>"IE","short_name"=>"Ireland","calling_code"=>"353"); $countries['IL'] = array("code"=>"IL","short_name"=>"Israel","calling_code"=>"972"); $countries['IT'] = array("code"=>"IT","short_name"=>"Italy","calling_code"=>"39"); $countries['JM'] = array("code"=>"JM","short_name"=>"Jamaica","calling_code"=>"1"); $countries['JP'] = array("code"=>"JP","short_name"=>"Japan","calling_code"=>"81"); $countries['JO'] = array("code"=>"JO","short_name"=>"Jordan","calling_code"=>"962"); $countries['KZ'] = array("code"=>"KZ","short_name"=>"Kazakhstan","calling_code"=>"7"); $countries['KE'] = array("code"=>"KE","short_name"=>"Kenya","calling_code"=>"254"); $countries['KI'] = array("code"=>"KI","short_name"=>"Kiribati","calling_code"=>"686"); $countries['XK'] = array("code"=>"XK","short_name"=>"Kosovo","calling_code"=>"381"); $countries['KW'] = array("code"=>"KW","short_name"=>"Kuwait","calling_code"=>"965"); $countries['KG'] = array("code"=>"KG","short_name"=>"Kyrgyzstan","calling_code"=>"996"); $countries['LA'] = array("code"=>"LA","short_name"=>"Laos","calling_code"=>"856"); $countries['LV'] = array("code"=>"LV","short_name"=>"Latvia","calling_code"=>"371"); $countries['LB'] = array("code"=>"LB","short_name"=>"Lebanon","calling_code"=>"961"); $countries['LS'] = array("code"=>"LS","short_name"=>"Lesotho","calling_code"=>"266"); $countries['LR'] = array("code"=>"LR","short_name"=>"Liberia","calling_code"=>"231"); $countries['LY'] = array("code"=>"LY","short_name"=>"Libya","calling_code"=>"218"); $countries['LI'] = array("code"=>"LI","short_name"=>"Liechtenstein","calling_code"=>"423"); $countries['LT'] = array("code"=>"LT","short_name"=>"Lithuania","calling_code"=>"370"); $countries['LU'] = array("code"=>"LU","short_name"=>"Luxembourg","calling_code"=>"352"); $countries['MO'] = array("code"=>"MO","short_name"=>"Macau","calling_code"=>"853"); $countries['MK'] = array("code"=>"MK","short_name"=>"Macedonia","calling_code"=>"389"); $countries['MG'] = array("code"=>"MG","short_name"=>"Madagascar","calling_code"=>"261"); $countries['MW'] = array("code"=>"MW","short_name"=>"Malawi","calling_code"=>"265"); $countries['MY'] = array("code"=>"MY","short_name"=>"Malaysia","calling_code"=>"60"); $countries['MV'] = array("code"=>"MV","short_name"=>"Maldives","calling_code"=>"960"); $countries['ML'] = array("code"=>"ML","short_name"=>"Mali","calling_code"=>"223"); $countries['MT'] = array("code"=>"MT","short_name"=>"Malta","calling_code"=>"356"); $countries['MH'] = array("code"=>"MH","short_name"=>"Marshall Islands","calling_code"=>"692"); $countries['MQ'] = array("code"=>"MQ","short_name"=>"Martinique","calling_code"=>"596"); $countries['MR'] = array("code"=>"MR","short_name"=>"Mauritania","calling_code"=>"222"); $countries['MU'] = array("code"=>"MU","short_name"=>"Mauritius","calling_code"=>"230"); $countries['YT'] = array("code"=>"YT","short_name"=>"Mayotte","calling_code"=>"262"); $countries['MX'] = array("code"=>"MX","short_name"=>"Mexico","calling_code"=>"52"); $countries['MD'] = array("code"=>"MD","short_name"=>"Moldova","calling_code"=>"373"); $countries['MC'] = array("code"=>"MC","short_name"=>"Monaco","calling_code"=>"377"); $countries['MN'] = array("code"=>"MN","short_name"=>"Mongolia","calling_code"=>"976"); $countries['ME'] = array("code"=>"ME","short_name"=>"Montenegro","calling_code"=>"382"); $countries['MS'] = array("code"=>"MS","short_name"=>"Montserrat","calling_code"=>"1"); $countries['MA'] = array("code"=>"MA","short_name"=>"Morocco","calling_code"=>"212"); $countries['MZ'] = array("code"=>"MZ","short_name"=>"Mozambique","calling_code"=>"258"); $countries['NA'] = array("code"=>"NA","short_name"=>"Namibia","calling_code"=>"264"); $countries['NR'] = array("code"=>"NR","short_name"=>"Nauru","calling_code"=>"674"); $countries['NP'] = array("code"=>"NP","short_name"=>"Nepal","calling_code"=>"977"); $countries['NL'] = array("code"=>"NL","short_name"=>"Netherlands","calling_code"=>"31"); $countries['AN'] = array("code"=>"AN","short_name"=>"Netherlands Antilles","calling_code"=>"599"); $countries['NC'] = array("code"=>"NC","short_name"=>"New Caledonia","calling_code"=>"687"); $countries['NZ'] = array("code"=>"NZ","short_name"=>"New Zealand","calling_code"=>"64"); $countries['NI'] = array("code"=>"NI","short_name"=>"Nicaragua","calling_code"=>"505"); $countries['NE'] = array("code"=>"NE","short_name"=>"Niger","calling_code"=>"227"); $countries['NG'] = array("code"=>"NG","short_name"=>"Nigeria","calling_code"=>"234"); $countries['NU'] = array("code"=>"NU","short_name"=>"Niue","calling_code"=>"683"); $countries['NF'] = array("code"=>"NF","short_name"=>"Norfolk Island","calling_code"=>"672"); $countries['KP'] = array("code"=>"KP","short_name"=>"North Korea","calling_code"=>"850"); $countries['MP'] = array("code"=>"MP","short_name"=>"Northern Mariana Islands","calling_code"=>"1"); $countries['NO'] = array("code"=>"NO","short_name"=>"Norway","calling_code"=>"47"); $countries['OM'] = array("code"=>"OM","short_name"=>"Oman","calling_code"=>"968"); $countries['PK'] = array("code"=>"PK","short_name"=>"Pakistan","calling_code"=>"92"); $countries['PW'] = array("code"=>"PW","short_name"=>"Palau","calling_code"=>"680"); $countries['PS'] = array("code"=>"PS","short_name"=>"Palestine","calling_code"=>"970"); $countries['PA'] = array("code"=>"PA","short_name"=>"Panama","calling_code"=>"507"); $countries['PG'] = array("code"=>"PG","short_name"=>"Papua New Guinea","calling_code"=>"675"); $countries['PY'] = array("code"=>"PY","short_name"=>"Paraguay","calling_code"=>"595"); $countries['PE'] = array("code"=>"PE","short_name"=>"Peru","calling_code"=>"51"); $countries['PH'] = array("code"=>"PH","short_name"=>"Philippines","calling_code"=>"63"); $countries['PL'] = array("code"=>"PL","short_name"=>"Poland","calling_code"=>"48"); $countries['PT'] = array("code"=>"PT","short_name"=>"Portugal","calling_code"=>"351"); $countries['PR'] = array("code"=>"PR","short_name"=>"Puerto Rico","calling_code"=>"1"); $countries['QA'] = array("code"=>"QA","short_name"=>"Qatar","calling_code"=>"974"); $countries['CG'] = array("code"=>"CG","short_name"=>"Republic of the Congo","calling_code"=>"242"); $countries['RE'] = array("code"=>"RE","short_name"=>"Réunion" ,"calling_code"=>"262"); $countries['RO'] = array("code"=>"RO","short_name"=>"Romania","calling_code"=>"40"); $countries['RU'] = array("code"=>"RU","short_name"=>"Russia","calling_code"=>"7"); $countries['RW'] = array("code"=>"RW","short_name"=>"Rwanda","calling_code"=>"250"); $countries['BL'] = array("code"=>"BL","short_name"=>"Saint Barthélemy" ,"calling_code"=>"590"); $countries['SH'] = array("code"=>"SH","short_name"=>"Saint Helena","calling_code"=>"290"); $countries['KN'] = array("code"=>"KN","short_name"=>"Saint Kitts and Nevis","calling_code"=>"1"); $countries['MF'] = array("code"=>"MF","short_name"=>"Saint Martin","calling_code"=>"590"); $countries['PM'] = array("code"=>"PM","short_name"=>"Saint Pierre and Miquelon","calling_code"=>"508"); $countries['VC'] = array("code"=>"VC","short_name"=>"Saint Vincent and the Grenadines","calling_code"=>"1"); $countries['WS'] = array("code"=>"WS","short_name"=>"Samoa","calling_code"=>"685"); $countries['SM'] = array("code"=>"SM","short_name"=>"San Marino","calling_code"=>"378"); $countries['ST'] = array("code"=>"ST","short_name"=>"São Tomé and Príncipe" ,"calling_code"=>"239"); $countries['SA'] = array("code"=>"SA","short_name"=>"Saudi Arabia","calling_code"=>"966"); $countries['SN'] = array("code"=>"SN","short_name"=>"Senegal","calling_code"=>"221"); $countries['RS'] = array("code"=>"RS","short_name"=>"Serbia","calling_code"=>"381"); $countries['SC'] = array("code"=>"SC","short_name"=>"Seychelles","calling_code"=>"248"); $countries['SL'] = array("code"=>"SL","short_name"=>"Sierra Leone","calling_code"=>"232"); $countries['SG'] = array("code"=>"SG","short_name"=>"Singapore","calling_code"=>"65"); $countries['SK'] = array("code"=>"SK","short_name"=>"Slovakia","calling_code"=>"421"); $countries['SI'] = array("code"=>"SI","short_name"=>"Slovenia","calling_code"=>"386"); $countries['SB'] = array("code"=>"SB","short_name"=>"Solomon Islands","calling_code"=>"677"); $countries['SO'] = array("code"=>"SO","short_name"=>"Somalia","calling_code"=>"252"); $countries['ZA'] = array("code"=>"ZA","short_name"=>"South Africa","calling_code"=>"27"); $countries['KR'] = array("code"=>"KR","short_name"=>"South Korea","calling_code"=>"82"); $countries['ES'] = array("code"=>"ES","short_name"=>"Spain","calling_code"=>"34"); $countries['LK'] = array("code"=>"LK","short_name"=>"Sri Lanka","calling_code"=>"94"); $countries['LC'] = array("code"=>"LC","short_name"=>"St. Lucia","calling_code"=>"1"); $countries['SD'] = array("code"=>"SD","short_name"=>"Sudan","calling_code"=>"249"); $countries['SR'] = array("code"=>"SR","short_name"=>"Surishort_name","calling_code"=>"597"); $countries['SZ'] = array("code"=>"SZ","short_name"=>"Swaziland","calling_code"=>"268"); $countries['SE'] = array("code"=>"SE","short_name"=>"Sweden","calling_code"=>"46"); $countries['CH'] = array("code"=>"CH","short_name"=>"Switzerland","calling_code"=>"41"); $countries['SY'] = array("code"=>"SY","short_name"=>"Syria","calling_code"=>"963"); $countries['TW'] = array("code"=>"TW","short_name"=>"Taiwan","calling_code"=>"886"); $countries['TJ'] = array("code"=>"TJ","short_name"=>"Tajikistan","calling_code"=>"992"); $countries['TZ'] = array("code"=>"TZ","short_name"=>"Tanzania","calling_code"=>"255"); $countries['TH'] = array("code"=>"TH","short_name"=>"Thailand","calling_code"=>"66"); $countries['BS'] = array("code"=>"BS","short_name"=>"The Bahamas","calling_code"=>"1"); $countries['GM'] = array("code"=>"GM","short_name"=>"The Gambia","calling_code"=>"220"); $countries['TL'] = array("code"=>"TL","short_name"=>"Timor-Leste","calling_code"=>"670"); $countries['TG'] = array("code"=>"TG","short_name"=>"Togo","calling_code"=>"228"); $countries['TK'] = array("code"=>"TK","short_name"=>"Tokelau","calling_code"=>"690"); $countries['TO'] = array("code"=>"TO","short_name"=>"Tonga","calling_code"=>"676"); $countries['TT'] = array("code"=>"TT","short_name"=>"Trinidad and Tobago","calling_code"=>"1"); $countries['TN'] = array("code"=>"TN","short_name"=>"Tunisia","calling_code"=>"216"); $countries['TR'] = array("code"=>"TR","short_name"=>"Turkey","calling_code"=>"90"); $countries['TM'] = array("code"=>"TM","short_name"=>"Turkmenistan","calling_code"=>"993"); $countries['TC'] = array("code"=>"TC","short_name"=>"Turks and Caicos Islands","calling_code"=>"1"); $countries['TV'] = array("code"=>"TV","short_name"=>"Tuvalu","calling_code"=>"688"); $countries['UG'] = array("code"=>"UG","short_name"=>"Uganda","calling_code"=>"256"); $countries['UA'] = array("code"=>"UA","short_name"=>"Ukraine","calling_code"=>"380"); $countries['AE'] = array("code"=>"AE","short_name"=>"United Arab Emirates","calling_code"=>"971"); $countries['GB'] = array("code"=>"GB","short_name"=>"United Kingdom","calling_code"=>"44"); $countries['US'] = array("code"=>"US","short_name"=>"United States","calling_code"=>"1"); $countries['UY'] = array("code"=>"UY","short_name"=>"Uruguay","calling_code"=>"598"); $countries['VI'] = array("code"=>"VI","short_name"=>"US Virgin Islands","calling_code"=>"1"); $countries['UZ'] = array("code"=>"UZ","short_name"=>"Uzbekistan","calling_code"=>"998"); $countries['VU'] = array("code"=>"VU","short_name"=>"Vanuatu","calling_code"=>"678"); $countries['VA'] = array("code"=>"VA","short_name"=>"Vatican City","calling_code"=>"39"); $countries['VE'] = array("code"=>"VE","short_name"=>"Venezuela","calling_code"=>"58"); $countries['VN'] = array("code"=>"VN","short_name"=>"Vietnam","calling_code"=>"84"); $countries['WF'] = array("code"=>"WF","short_name"=>"Wallis and Futuna","calling_code"=>"681"); $countries['YE'] = array("code"=>"YE","short_name"=>"Yemen","calling_code"=>"967"); $countries['ZM'] = array("code"=>"ZM","short_name"=>"Zambia","calling_code"=>"260"); $countries['ZW'] = array("code"=>"ZW","short_name"=>"Zimbabwe","calling_code"=>"263"); and I simply fetch the values I want using: $country_code=$_SERVER["HTTP_CF_IPCOUNTRY"]; $country=$countries[''.$country_code.'']; Thus eliminating the need to connect to the DB and use MYSQL. My question is, is it bad to have this array loaded several times a second? Will it impact performance a lot? Should I simply have a connection to the DB like I previously did? The server has 16GB of RAM and 8 cores. We're talking about 40-50 thousand visits per day. Thanks!
First: $country=$countries[''.$country_code.'']; can be replaced with this $country=$countries[$country_code]; This array is definitly the better choice over a Database. Each connection needs some time and arrays can be accessed way faster. If you want to know exactly how the difference is, you could use this "mini test suite" t determine the runtime difference. $start1 = microtime(true); for($i = 0; $i < 10000; $i++) { //With database } $end1 = microtime(true); unset(); // The variables which might have been set the section above $start2 = microtime(true); for($i = 0; $i < 10000; $i++) { //code with array } $end2 = microtime(true); echo $end1-$start1."<br />"; echo $end2-$start2."<br />"; I hope this helps you, if not please let me know.
Invalid parameter number: parameter was not defined, parameters are mapped?
Pretty sure I mapped the parameters right but still getting this error. I've tried matching up the parameters with the query and they match fine. I've also tried several other things but nothing is solving the issue. Any ideas? $stmt = $conn->prepare("UPDATE stores SET Name = :Name, Legal_Entity__c = :Legal_Entity__c, Opening_Date__c = :Opening_Date__c, Owner_Type__c = :Owner_Type__c, Yumtracker_Status__c = :Yumtracker_Status__c, Hypercare_Status__c = :Hypercare_Status__c,BOH_Type__c = :BOH_Type__c,Store_Type__c = :Store_Type__c,Address_Line_1__c = :Address_Line_1__c,Address_Line_2__c = :Address_Line_2__c,City__c = :City__c,State__c = :State__c,Zip__c = :Zip__c,Store_Email_Address__c = :Store_Email_Address__c,Time_Zone__c = :Time_Zone__c,Area_Coach__c = :Area_Coach__c,RGM__c = :RGM__c,RTO_Date__c = :RTO_Date__c,Ground_Break_Date__c = :Ground_Break_Date__c,BOH_Install_Date__c = :BOH_Install_Date__c,Primary_BB_Install_Date__c = :Primary_BB_Install_Date__c,TTO_Install_Date__c = :TTO_Install_Date__c,Pre_Cable_Date__c = :Pre_Cable_Date__c,HME_Install_Date__c = :HME_Install_Date__c,Install_Date__c = :Install_Date__c,POS_Install_Date__c = :POS_Install_Date__c,Backup_BB_Install_Date__c = :Backup_BB_Install_Date__c,Telco_Install_Date__c = :Telco_Install_Date__c,Site_Survey_Date__c = :Site_Survey_Date__c,Opening_Support_Date__c = :Opening_Support_Date__c,Sea_Trial__c = :Sea_Trial__c,Mobile__c = :Mobile__c,OCB__c = :OCB__c,BOH__c = :BOH__c,KDS__c = :KDS__c,POS__c = :POS__c,HME__c = :HME__c,Airtight__c = :Airtight__c,LZ__c = :LZ__c,HZ__c = :HZ__c,Technology_Check_Last_Update__c = :Technology_Check_Last_Update__c,Verify_Store_is_in_EDM__c = :Verify_Store_is_in_EDM__c,Verify_AC_RGM_have_INIT_checklist__c = :Verify_AC_RGM_have_INIT_checklist__c,Verify_TACO_eRes_is_INIT__c = :Verify_TACO_eRes_is_INIT__c,Verify_no_issues_with_Tech__c = :Verify_no_issues_with_Tech__c,Verify_Store_Opened__c = :Verify_Store_Opened__c,Verify_store_shows_open_in_Remedy__c = :Verify_store_shows_open_in_Remedy__c,Verify_Gift_Cards_are_active__c = :Verify_Gift_Cards_are_active__c,Days_in_Implementation__c = :Days_in_Implementation__c,Days_in_Hypercare__c = :Days_in_Hypercare__c,Days_to_Stability__c = :Days_to_Stability__c,Verify_Store_can_access_LZ_HZ__c = :Verify_Store_can_access_LZ_HZ__c,Verify_Mobile_MIDs_sent_to_Tillster__c = :Verify_Mobile_MIDs_sent_to_Tillster__c,Verify_store_has_no_issues__c = :Verify_store_has_no_issues__c,Verify_Mobile_and_Gift_Card_setup_start__c = :Verify_Mobile_and_Gift_Card_setup_start__c WHERE Id = '$recordID'"); $stmt->bindParam(':Name', $updatedRecord->Name); $stmt->bindParam(':Legal_Entity__c', $updatedRecord->Legal_Entity__c); $stmt->bindParam(':Opening_Date__c', $updatedRecord->Opening_Date__c); $stmt->bindParam(':Owner_Type__c', $updatedRecord->Owner_Type__c); $stmt->bindParam(':YumTracker_Status__c', $updatedRecord->YumTracker_Status__c); $stmt->bindParam(':Hypercare_Status__c', $updatedRecord->Hypercare_Status__c); $stmt->bindParam(':BOH_Type__c', $updatedRecord->BOH_Type__c); $stmt->bindParam(':Store_Type__c', $updatedRecord->Store_Type__c); $stmt->bindParam(':Address_Line_1__c', $updatedRecord->Address_Line_1__c); $stmt->bindParam(':Address_Line_2__c', $updatedRecord->Address_Line_2__c); $stmt->bindParam(':City__c', $updatedRecord->City__c); $stmt->bindParam(':State__c', $updatedRecord->State__c); $stmt->bindParam(':Zip__c', $updatedRecord->Zip__c); $stmt->bindParam(':Store_Email_Address__c', $updatedRecord->Store_Email_Address__c); $stmt->bindParam(':Time_Zone__c', $updatedRecord->Time_Zone__c); $stmt->bindParam(':Area_Coach__c', $updatedRecord->Area_Coach__c); $stmt->bindParam(':RGM__c', $updatedRecord->RGM__c); $stmt->bindParam(':RTO_Date__c', $updatedRecord->RTO_Date__c); $stmt->bindParam(':Ground_Break_Date__c', $updatedRecord->Ground_Break_Date__c); $stmt->bindParam(':BOH_Install_Date__c', $updatedRecord->BOH_Install_Date__c); $stmt->bindParam(':Primary_BB_Install_Date__c', $updatedRecord->Primary_BB_Install_Date__c); $stmt->bindParam(':TTO_Install_Date__c', $updatedRecord->TTO_Install_Date__c); $stmt->bindParam(':Pre_Cable_Date__c', $updatedRecord->Pre_Cable_Date__c); $stmt->bindParam(':HME_Install_Date__c', $updatedRecord->HME_Install_Date__c); $stmt->bindParam(':Install_Date__c', $updatedRecord->Install_Date__c); $stmt->bindParam(':POS_Install_Date__c', $updatedRecord->POS_Install_Date__c); $stmt->bindParam(':Backup_BB_Install_Date__c', $updatedRecord->Backup_BB_Install_Date__c); $stmt->bindParam(':Telco_Install_Date__c', $updatedRecord->Telco_Install_Date__c); $stmt->bindParam(':Site_Survey_Date__c', $updatedRecord->Site_Survey_Date__c); $stmt->bindParam(':Opening_Support_Date__c', $updatedRecord->Opening_Support_Date__c); $stmt->bindParam(':Sea_Trial__c', $updatedRecord->Sea_Trial__c); $stmt->bindParam(':Mobile__c', $updatedRecord->Mobile__c); $stmt->bindParam(':OCB__c', $updatedRecord->OCB__c); $stmt->bindParam(':BOH__c', $updatedRecord->BOH__c); $stmt->bindParam(':KDS__c', $updatedRecord->KDS__c); $stmt->bindParam(':POS__c', $updatedRecord->POS__c); $stmt->bindParam(':HME__c', $updatedRecord->HME__c); $stmt->bindParam(':Airtight__c', $updatedRecord->Airtight__c); $stmt->bindParam(':LZ__c', $updatedRecord->LZ__c); $stmt->bindParam(':HZ__c', $updatedRecord->HZ__c); $stmt->bindParam(':Technology_Check_Last_Update__c', $updatedRecord->Technology_Check_Last_Update__c); $stmt->bindParam(':Verify_Store_is_in_EDM__c', $updatedRecord->Verify_Store_is_in_EDM__c); $stmt->bindParam(':Verify_AC_RGM_have_INIT_checklist__c', $updatedRecord->Verify_AC_RGM_have_INIT_checklist__c); $stmt->bindParam(':Verify_TACO_eRes_is_INIT__c', $updatedRecord->Verify_TACO_eRes_is_INIT__c); $stmt->bindParam(':Verify_no_issues_with_Tech__c', $updatedRecord->Verify_no_issues_with_Tech__c); $stmt->bindParam(':Verify_Store_Opened__c', $updatedRecord->Verify_Store_Opened__c); $stmt->bindParam(':Verify_store_shows_open_in_Remedy__c', $updatedRecord->Verify_store_shows_open_in_Remedy__c); $stmt->bindParam(':Verify_Gift_Cards_are_active__c', $updatedRecord->Verify_Gift_Cards_are_active__c); $stmt->bindParam(':Days_in_Implementation__c', $updatedRecord->Days_in_Implementation__c); $stmt->bindParam(':Days_in_Hypercare__c', $updatedRecord->Days_in_Hypercare__c); $stmt->bindParam(':Days_to_Stability__c', $updatedRecord->Days_to_Stability__c); $stmt->bindParam(':Verify_Store_can_access_LZ_HZ__c', $updatedRecord->Verify_Store_can_access_LZ_HZ__c); $stmt->bindParam(':Verify_Mobile_MIDs_sent_to_Tillster__c', $updatedRecord->Verify_Mobile_MIDs_sent_to_Tillster__c); $stmt->bindParam(':Verify_store_has_no_issues__c', $updatedRecord->Verify_store_has_no_issues__c); $stmt->bindParam(':Verify_Mobile_and_Gift_Card_setup_start__c', $updatedRecord->Verify_Mobile_and_Gift_Card_setup_start__c); $stmt->execute();
Shipping Address not displayed in the Paypal Transaction Details page
I am unable to get the shipping Addresses of my customers in the 'Transacton Details' page. It's displaying the following message. 'We have no shipping address on file' The issue mainly happens when users use PaypalPro (Direct Payment) option. Can anyone help me in this issue. Note: This is my code corresponding to the DoDirectPayment Request. class ProAuthorizeRequest extends AbstractRequest { protected $action = 'Authorization'; public function getData() { $data = $this->getBaseData('DoDirectPayment'); $this->validate('amount', 'card'); $this->getCard()->validate(); $data['PAYMENTACTION'] = $this->action; $data['AMT'] = $this->getAmount(); $data['CURRENCYCODE'] = $this->getCurrency(); $data['INVNUM'] = $this->getTransactionId(); $data['DESC'] = $this->getDescription(); // add credit card details $data['ACCT'] = $this->getCard()->getNumber(); $data['CREDITCARDTYPE'] = $this->getCard()->getBrand(); $data['EXPDATE'] = $this->getCard()->getExpiryMonth().$this->getCard()->getExpiryYear(); $data['STARTDATE'] = $this->getCard()->getStartMonth().$this->getCard()->getStartYear(); $data['CVV2'] = $this->getCard()->getCvv(); $data['ISSUENUMBER'] = $this->getCard()->getIssueNumber(); $data['IPADDRESS'] = $this->getClientIp(); $data['FIRSTNAME'] = $this->getCard()->getFirstName(); $data['LASTNAME'] = $this->getCard()->getLastName(); $data['EMAIL'] = $this->getCard()->getEmail(); $data['STREET'] = $this->getCard()->getAddress1(); $data['STREET2'] = $this->getCard()->getAddress2(); $data['CITY'] = $this->getCard()->getCity(); $data['STATE'] = $this->getCard()->getState(); $data['ZIP'] = $this->getCard()->getPostcode(); $data['COUNTRYCODE'] = strtoupper($this->getCard()->getCountry()); return $data; } }
For DoDirectPayment you need to also include the SHIPTO variables: public function getData() { $data = $this->getBaseData('DoDirectPayment'); $this->validate('amount', 'card'); $this->getCard()->validate(); $data['PAYMENTACTION'] = $this->action; $data['AMT'] = $this->getAmount(); $data['CURRENCYCODE'] = $this->getCurrency(); $data['INVNUM'] = $this->getTransactionId(); $data['DESC'] = $this->getDescription(); // add credit card details $data['ACCT'] = $this->getCard()->getNumber(); $data['CREDITCARDTYPE'] = $this->getCard()->getBrand(); $data['EXPDATE'] = $this->getCard()->getExpiryMonth().$this->getCard()->getExpiryYear(); $data['STARTDATE'] = $this->getCard()->getStartMonth().$this->getCard()->getStartYear(); $data['CVV2'] = $this->getCard()->getCvv(); $data['ISSUENUMBER'] = $this->getCard()->getIssueNumber(); $data['IPADDRESS'] = $this->getClientIp(); $data['FIRSTNAME'] = $this->getCard()->getFirstName(); $data['LASTNAME'] = $this->getCard()->getLastName(); $data['EMAIL'] = $this->getCard()->getEmail(); $data['STREET'] = $this->getCard()->getAddress1(); $data['STREET2'] = $this->getCard()->getAddress2(); $data['CITY'] = $this->getCard()->getCity(); $data['STATE'] = $this->getCard()->getState(); $data['ZIP'] = $this->getCard()->getPostcode(); $data['COUNTRYCODE'] = strtoupper($this->getCard()->getCountry()); //shipping information as you want displayed on transaction details. name is a single field. $data['SHIPTONAME'] = $this->getCard()->getFirstName() . " " . $this->getCard()->getLastName(); $data['SHIPTOSTREET'] = $this->getCard()->getAddress1(); $data['SHIPTOSTREET2'] = $this->getCard()->getAddress2(); $data['SHIPTOCITY'] = $this->getCard()->getCity(); $data['SHIPTOSTATE'] = $this->getCard()->getState(); $data['SHIPTOZIP'] = $this->getCard()->getPostcode(); $data['SHIPTOCOUNTRYCODE'] = strtoupper($this->getCard()->getCountry()); return $data; }
Values of an array showing wrong values
I'm trying to use files to set the language. $_LANG[000] = 'Inicío'; $_LANG[001] = 'Principal'; $_LANG[002] = 'Procurar'; $_LANG[003] = 'Estatísticas'; $_LANG[004] = 'Calendário'; $_LANG[005] = 'Pagamentos'; $_LANG[006] = 'Finanças'; $_LANG[007] = 'Gestão'; $_LANG[008] = 'Administração'; $_LANG[009] = 'Boleto Bancário'; $_LANG[010] = 'Cartão de Crédito'; $_LANG[011] = 'Boleto'; $_LANG[012] = 'Visa'; $_LANG[013] = 'MasterCard'; $_LANG[014] = 'HiperCard'; $_LANG[015] = 'Diners Club'; $_LANG[016] = 'American Express'; $_LANG[017] = 'Itaú'; $_LANG[018] = 'Caixa'; $_LANG[019] = 'Bradesco'; $_LANG[020] = 'Banrisul'; $_LANG[021] = 'Visan Eletron'; $_LANG[022] = 'Débido'; $_LANG[023] = 'Crédito'; $_LANG[024] = 'Check In'; $_LANG[025] = 'Check Out'; $_LANG[026] = 'Verificar'; $_LANG[027] = 'Verificando'; $_LANG[028] = 'Fatura'; $_LANG[029] = 'Módulos'; $_LANG[030] = 'Notas Escolares'; $_LANG[031] = 'Faltas'; $_LANG[032] = 'Ano Létivo'; $_LANG[033] = 'Desempenho Escolar'; $_LANG[034] = 'Sumário'; $_LANG[035] = 'Cadastrar Usuário'; $_LANG[036] = 'Novo Usuário'; $_LANG[037] = 'Erro 404'; $_LANG[038] = 'Página Não Dísponivel'; $_LANG[039] = 'Página Não Encontrada'; $_LANG[040] = 'Galeria'; $_LANG[041] = 'Perfil'; $_LANG[042] = 'Configuração'; $_LANG[043] = 'Configurações'; $_LANG[044] = 'Mudar Senha'; $_LANG[045] = 'Sair'; $_LANG[046] = 'Encerrar'; $_LANG[047] = 'Sessão'; $_LANG[048] = 'Mensagens'; $_LANG[049] = 'Notificações'; $_LANG[050] = 'Ver todas notificações'; $_LANG[051] = 'Ver todas mensagens'; $_LANG[052] = 'Ver notificações'; $_LANG[053] = 'Ver mensagem'; $_LANG[054] = 'Aprovado'; $_LANG[055] = 'Reprovado'; $_LANG[056] = 'Recuperação'; $_LANG[057] = '1ª'; $_LANG[058] = '2ª'; $_LANG[059] = '3ª'; $_LANG[060] = '4ª'; $_LANG[061] = '5ª'; $_LANG[062] = '6ª'; $_LANG[063] = '1º'; $_LANG[064] = '2º'; $_LANG[065] = '3º'; $_LANG[066] = '4º'; $_LANG[067] = '5º'; $_LANG[068] = '6º'; $_LANG[069] = 'Chamada'; $_LANG[070] = 'Declaração'; $_LANG[071] = 'Escolar'; $_LANG[072] = 'Transfêrencia'; $_LANG[073] = 'Notícia'; $_LANG[074] = 'Notícias'; $_LANG[075] = 'Acadêmico'; $_LANG[076] = 'Ideias'; $_LANG[077] = 'Ajuda'; $_LANG[078] = 'Suporte Técnico'; $_LANG[079] = 'Relatório'; $_LANG[080] = 'Horários'; $_LANG[081] = 'Quadro de Horários'; $_LANG[082] = 'Notas / Faltas'; $_LANG[083] = 'Plano Ensino'; $_LANG[084] = 'Imprimir'; $_LANG[085] = 'Financeira'; $_LANG[086] = 'Word'; $_LANG[087] = 'Exel'; $_LANG[088] = 'PowerPoint'; $_LANG[089] = 'Skype'; $_LANG[090] = 'Outlook'; $_LANG[091] = 'E-mail'; $_LANG[092] = 'Dúvidas'; $_LANG[093] = 'Bimestre'; $_LANG[094] = 'Semestre'; then I want showing "Inicío" for that I need to insert print $ _LANG [000]; the problem is that it shows the right value only starting from 010 I do not know why
You're prefixing the keys with 0, so they're being treated as octal numbers. e.g. $_LANG[027(octal)] is actually $_LANG[23(decimal) $_LANG[010(octal)] is actually $_LANG[8(decimal)] Either use strings: $_LANG['027'] or normal decimals: $_LANG[27]