Hello, I am getting a weird error when i try to run this array:
//leafly api keys
$appID ='Blah';
$appKEY = 'blah';
//init curl
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://data.leafly.com/strains/".strtolower($data)); //change the strain dynamically of course for your app
curl_setopt($ch,CURLOPT_HTTPHEADER,array('APP_ID:'.$appID,'APP_KEY:'.$appKEY));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
//Clean it into an php array object and set var
$cleaned_response = json_decode($output,true);
foreach($cleaned_response as $image){
//continue;
echo'<img height="100" width="100" src="'.$image['photos'].'"/>'; //<--Line 73
}
// Look at it
print_r($cleaned_response);
// close curl resource to free up system resources
$output = curl_init();
then when i run the script, i get this:
<b>Warning</b>: Illegal string offset 'thumb' in <b>C:\xampp\htdocs\~review\search1.php</b> on line <b>73</b><br />
The array that is returned is:
array(25) { ["sl_translate"]=> string(37) "description,descriptionPlain,category" ["id"]=> int(239) ["slug"]=> string(9) "pineapple" ["name"]=> string(9) "Pineapple" ["symbol"]=> string(3) "Pin" ["category"]=> string(6) "Hybrid" ["description"]=> string(247) "
Pineapple marijuana strain is a phenotype F2 of the ERSB indica Pineapple that was inbred and feminized. The buds smell like the actual fruit of pineapple and even tend to resemble the fruit when growing. Flowering time is 7-8 weeks.
" ["descriptionPlain"]=> string(240) "Pineapple marijuana strain is a phenotype F2 of the ERSB indica Pineapple that was inbred and feminized. The buds smell like the actual fruit of pineapple and even tend to resemble the fruit when growing. Flowering time is 7-8 weeks. " ["aka"]=> NULL ["rating"]=> float(3.9) ["reviewCount"]=> int(70) ["flavors"]=> array(5) { [0]=> array(2) { ["name"]=> string(9) "Pineapple" ["score"]=> float(62.237394957983) } [1]=> array(2) { ["name"]=> string(5) "Sweet" ["score"]=> float(35.136554621849) } [2]=> array(2) { ["name"]=> string(8) "Tropical" ["score"]=> float(22.111344537815) } [3]=> array(2) { ["name"]=> string(7) "Pungent" ["score"]=> float(14.443277310924) } [4]=> array(2) { ["name"]=> string(6) "Earthy" ["score"]=> float(9.453781512605) } } ["effects"]=> array(5) { [0]=> array(2) { ["name"]=> string(5) "Happy" ["score"]=> float(98.203419298754) } [1]=> array(2) { ["name"]=> string(7) "Relaxed" ["score"]=> float(89.338235294118) } [2]=> array(2) { ["name"]=> string(8) "Euphoric" ["score"]=> float(87.393146913938) } [3]=> array(2) { ["name"]=> string(8) "Uplifted" ["score"]=> float(76.494132135613) } [4]=> array(2) { ["name"]=> string(6) "Hungry" ["score"]=> float(60.111199652275) } } ["symptoms"]=> array(5) { [0]=> array(2) { ["name"]=> string(6) "Stress" ["score"]=> float(45.631700956245) } [1]=> array(2) { ["name"]=> string(4) "Pain" ["score"]=> float(24.199507389163) } [2]=> array(2) { ["name"]=> string(10) "Depression" ["score"]=> float(20.876195305708) } [3]=> array(2) { ["name"]=> string(6) "Nausea" ["score"]=> float(20.198855404231) } [4]=> array(2) { ["name"]=> string(8) "Insomnia" ["score"]=> float(17.920530281078) } } ["conditions"]=> array(5) { [0]=> array(2) { ["name"]=> string(7) "Anxiety" ["score"]=> float(39.906911040278) } [1]=> array(2) { ["name"]=> string(8) "ADD/ADHD" ["score"]=> float(12.132352941176) } [2]=> array(2) { ["name"]=> string(9) "Migraines" ["score"]=> float(7.0197044334975) } [3]=> array(2) { ["name"]=> string(4) "PTSD" ["score"]=> float(4.4642857142857) } [4]=> array(2) { ["name"]=> string(9) "Arthritis" ["score"]=> float(2.6785714285714) } } ["negatives"]=> array(5) { [0]=> array(2) { ["name"]=> string(9) "Dry Mouth" ["score"]=> float(33.839829035062) } [1]=> array(2) { ["name"]=> string(8) "Dry Eyes" ["score"]=> float(14.593596059113) } [2]=> array(2) { ["name"]=> string(5) "Dizzy" ["score"]=> float(11.516589394378) } [3]=> array(2) { ["name"]=> string(8) "Headache" ["score"]=> float(4.987684729064) } [4]=> array(2) { ["name"]=> string(8) "Paranoid" ["score"]=> float(3.8793103448276) } } ["articlesAvailable"]=> bool(true)
["photos"]=> array(4) { [0]=> array(3) { ["uploaded"]=> string(21) "/Date(1412910713961)/" ["thumb"]=> string(70) "http://leafly.blob.core.windows.net/reviews/pineapple_100x100_7461.jpg" ["fullsize"]=> string(90) "http://d3odcnigi1nnzz.cloudfront.net/cdn/strain-photo/200302/b/pineapple__primary_6bd8.jpg" } [1]=> array(3) { ["uploaded"]=> string(21) "/Date(1411943182488)/" ["thumb"]=> string(70) "http://leafly.blob.core.windows.net/reviews/pineapple_100x100_8a6d.jpg" ["fullsize"]=> string(90) "http://d3odcnigi1nnzz.cloudfront.net/cdn/strain-photo/194765/b/pineapple__primary_7c28.jpg" } [2]=> array(3) { ["uploaded"]=> string(21) "/Date(1411869502007)/" ["thumb"]=> string(70) "http://leafly.blob.core.windows.net/reviews/pineapple_100x100_e04b.jpg" ["fullsize"]=> string(90) "http://d3odcnigi1nnzz.cloudfront.net/cdn/strain-photo/194634/b/pineapple__primary_f551.jpg" } [3]=> array(3) { ["uploaded"]=> string(21) "/Date(1408810977356)/" ["thumb"]=> string(70) "http://leafly.blob.core.windows.net/reviews/pineapple_100x100_b38d.jpg" ["fullsize"]=> string(89) "http://d3odcnigi1nnzz.cloudfront.net/cdn/strain-photo/177162/b/pineapple_825x550_8b43.jpg" } }
["popularCities"]=> array(10) { [0]=> string(11) "Portland,OR" [1]=> string(9) "Eugene,OR" [2]=> string(14) "Los Angeles,CA" [3]=> string(10) "Seattle,WA" [4]=> string(2) "CA" [5]=> string(10) "Spokane,WA" [6]=> string(9) "Tacoma,WA" [7]=> string(10) "Barstow,CA" [8]=> string(7) "Bend,OR" [9]=> string(11) "Berkeley,CA" } ["permalink"]=> string(38) "http://www.leafly.com/hybrid/pineapple" ["starImage"]=> string(45) "//d3odcnigi1nnzz.cloudfront.net/stars/3.9/240" ["testGraph"]=> NULL ["weakDescription"]=> bool(false) ["parents"]=> array(0) { } ["growInfo"]=> array(8) { ["difficulty"]=> NULL ["preferredMedium"]=> NULL ["floweringDays"]=> int(0) ["outdoorFinish"]=> NULL ["height"]=> NULL ["averageYield"]=> NULL ["environment"]=> NULL ["growNotes"]=> string(0) "" } }
I seperated the photo array element.
I am not sure what i am doing wrong here. Seems to be the correct structure for it...