以下api输出转换为php foreach循环

php code here

<?php
$keywords = $this->input->post('search');

if ($keywords)
    {
    $url = 'https://www.googleapis.com/customsearch/v1?key=xxxx&cx=xxxxx&q=' . urlencode($keywords) . '';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    $data = curl_exec($ch);
    curl_close($ch);
    $data = (array)json_decode($data);

    // print_r($keys = array_keys($data));exit;

    print_r($data);
    exit;
}

This is indexs:

Array ( 
         [0] => kind 
         [1] => url 
         [2] => queries 
         [3] => context 
         [4] => searchInformation 
         [5] => items 
     )

I want to get items array detail have title url displayurl

This is output i have

    Array ( [kind] => customsearch#search [url] => stdClass Object ( [type] => application/json [template] => https://www.googleapis.com/customsearch/v1?q={searchTerms}&num={count?}&start={startIndex?}&lr={language?}&safe={safe?}&cx={cx?}&cref={cref?}&sort={sort?}&filter={filter?}&gl={gl?}&cr={cr?}&googlehost={googleHost?}&c2coff={disableCnTwTranslation?}&hq={hq?}&hl={hl?}&siteSearch={siteSearch?}&siteSearchFilter={siteSearchFilter?}&exactTerms={exactTerms?}&excludeTerms={excludeTerms?}&linkSite={linkSite?}&orTerms={orTerms?}&relatedSite={relatedSite?}&dateRestrict={dateRestrict?}&lowRange={lowRange?}&highRange={highRange?}&searchType={searchType}&fileType={fileType?}&rights={rights?}&imgSize={imgSize?}&imgType={imgType?}&imgColorType={imgColorType?}&imgDominantColor={imgDominantColor?}&alt=json ) [queries] => stdClass Object ( [request] => Array ( [0] => stdClass Object ( [title] => Google Custom Search - what is definition of astrology [totalResults] => 330000 [searchTerms] => what is definition of astrology [count] => 10 [startIndex] => 1 [inputEncoding] => utf8 [outputEncoding] => utf8 [safe] => off [cx] => 010407088344546736418:onjj7gscy2g ) ) [nextPage] => Array ( [0] => stdClass Object ( [title] => Google Custom Search - what is definition of astrology [totalResults] => 330000 [searchTerms] => what is definition of astrology [count] => 10 [startIndex] => 11 [inputEncoding] => utf8 [outputEncoding] => utf8 [safe] => off [cx] => 010407088344546736418:onjj7gscy2g ) ) ) [context] => stdClass Object ( [title] => test ) [searchInformation] => stdClass Object ( [searchTime] => 0.262633 [formattedSearchTime] => 0.26 [totalResults] => 330000 [formattedTotalResults] => 330,000 ) [items] => Array ( [0] => stdClass Object ( [kind] => customsearch#result [title] => Astrology | Definition of Astrology by Merriam-Webster [htmlTitle] => Astrology | Definition of Astrology by Merriam-Webster [link] => http://www.merriam-webster.com/dictionary/astrology [displayLink] => www.merriam-webster.com [snippet] => the study of how the positions of the stars and movements of the planets have a supposed influence on events and on the lives and behavior of people. Source: ... [htmlSnippet] => the study of how the positions of the stars and movements of the planets have a 
    supposed influence on events and on the lives and behavior of people. Source: ... [cacheId] => ANMK1sr9oTsJ [formattedUrl] => www.merriam-webster.com/dictionary/astrology [htmlFormattedUrl] => www.merriam-webster.com/dictionary/astrology [pagemap] => stdClass Object ( [metatags] => Array ( [0] => stdClass Object ( [fb:app_id] => 178450008855735 [viewport] => width=device-width, initial-scale=1.0 [og:title] => Definition of ASTROLOGY [og:image] => http://assets2.merriam-webster.com/mw/static/social-media-share/mw-logo-245x245@1x.png [og:url] => http://www.merriam-webster.com/dictionary/astrology [og:description] => the study of how the positions of the stars and movements of the planets have a supposed influence on events and on the lives and behavior of people See the full definition… [twitter:title] => Definition of ASTROLOGY [twitter:image] => http://assets2.merriam-webster.com/mw/static/social-media-share/mw-logo-245x245@1x.png [twitter:url] => http://www.merriam-webster.com/dictionary/astrology [twitter:description] => the study of how the positions of the stars and movements of the planets have a supposed influence on events and on the lives and behavior of people See the full definition… [twitter:card] => summary [twitter:site] => @MerriamWebster ) ) [cse_image] => Array ( [0] => stdClass Object ( [src] => http://assets2.merriam-webster.com/mw/static/social-media-share/mw-logo-245x245@1x.png ) ) ) ) [1] => stdClass Object ( [kind] => customsearch#result [title] => Astrology | Define Astrology at Dictionary.com [htmlTitle] => Astrology | Define Astrology at Dictionary.com [link] => http://www.dictionary.com/browse/astrology [displayLink] => www.dictionary.com [snippet] => Astrology definition, the study that assumes and attempts to interpret the influence of the heavenly bodies on human affairs. See more. [htmlSnippet] => Astrology definition, the study that assumes and attempts to interpret the 
    influence of the heavenly bodies on human affairs. See more. [cacheId] => WLC0PJ4DSrkJ [formattedUrl] => www.dictionary.com/browse/astrology [htmlFormattedUrl] => www.dictionary.com/browse/astrology [pagemap] => stdClass Object ( [metatags] => Array ( [0] => stdClass Object ( [fb:admins] => 100000304287730;109125464873 [og:site_name] => Dictionary.com [og:image] => http://static.sfdict.com/dcom/img/social_logo-b8e2f.png [fb:app_id] => 127444090629600 [msvalidate.01] => DF5542D7723770377E9ABFF59AC1DC97 [viewport] => width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no [og:title] => the definition of astrology [og:url] => http://www.dictionary.com/browse/astrology ) ) [cse_image] => Array ( [0] => stdClass Object ( [src] => http://static.sfdict.com/dcom/img/social_logo-b8e2f.png ) ) ) ) [2] => stdClass Object ( [kind] => customsearch#result [title] => Astrology - definition of astrology by The Free Dictionary [htmlTitle] => Astrology - definition of astrology by The Free Dictionary [link] => http://www.thefreedictionary.com/astrology [displayLink] => www.thefreedictionary.com [snippet] => The study of the positions and motions of celestial bodies in the belief that they have an influence on the course of natural earthly occurrences and human affairs  ... [htmlSnippet] => The study of the positions and motions of celestial bodies in the belief that they result [title] => Astrologer | Define Astrologer at Dictionary.com [htmlTitle] => Astrologer | Define Astrologer at Dictionary.com [link] => http://www.dictionary.com/browse/astrologer [displayLink] => www.dictionary.com [snippet] => Astrologer definition, the study that assumes and attempts to interpret the influence of the heavenly bodies on human affairs. See more. [htmlSnippet] => Astrologer definition, the study that assumes and attempts to interpret the 
influence of the heavenly bodies on human affairs. See more. [cacheId] => H2RT6ZTkUuEJ [formattedUrl] => www.dictionary.com/browse/astrologer [htmlFormattedUrl] => www.dictionary.com/browse/astrologer [pagemap] => stdClass Object ( [metatags] => Array ( [0] => stdClass Object ( [fb:admins] => 100000304287730;109125464873 [og:site_name] => Dictionary.com [og:image] => http://static.sfdict.com/dcom/img/social_logo-b8e2f.png [fb:app_id] => 127444090629600 [msvalidate.01] => DF5542D7723770377E9ABFF59AC1DC97 [viewport] => width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no [og:title] => the definition of astrologer [og:url] => http://www.dictionary.com/browse/astrologer ) ) [cse_image] => Array ( [0] => stdClass Object ( [src] => http://static.sfdict.com/dcom/img/social_logo-b8e2f.png ) ) ) ) [4] => stdClass Object ( [kind] => customsearch#result [title] => Astrology - Wikipedia, the free encyclopedia [htmlTitle] => Astrology - Wikipedia, the free encyclopedia [link] => https://en.wikipedia.org/wiki/Astrology [displayLink] => en.wikipedia.org [snippet] => Astrology is the study of the movements and relative positions of celestial objects as a means ..... In contrast, John Gower in the fourteenth century defined astrology as essentially limited to the making of predictions. The influence of the stars was ... [htmlSnippet] => Astrology is the study of the movements and relative positions of celestial objects 
as a means ..... In contrast, John Gower in the fourteenth century defined 
astrology as essentially limited to the making of predictions. The influence of the 
stars was ... [cacheId] => rEWjgAssJe0J [formattedUrl] => https://en.wikipedia.org/wiki/Astrology [htmlFormattedUrl] => https://en.wikipedia.org/wiki/Astrology [pagemap] => stdClass Object ( [cse_thumbnail] => Array ( [0] => stdClass Object ( [width] => 216 [height] => 216 [src] => https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSiwX2lV-iw3K0XHSaKJuE7mDToeIsFgBquYRJ9jlW2-A3TJ3hMkmkLEO4 ) ) [metatags] => Array ( [0] => stdClass Object ( [referrer] => origin-when-cross-origin ) ) [cse_image] => Array ( [0] => stdClass Object ( [src] => https://upload.wikimedia.org/wikipedia/commons/thumb/1/12/Venice_ast_sm.jpg/270px-Venice_ast_sm.jpg ) ) ) ) [5] => stdClass Object ( [kind] => customsearch#result [title] => Astrology - Definition and Meaning, Bible Dictionary [htmlTitle] => Astrology - Definition and Meaning, Bible Dictionary [link] => http://www.biblestudytools.com/dictionary/astrology/ [displayLink] => www.biblestudytools.com