-4

in my blade i want to concatenate a variable in blade iframe youtube video id from my api.

this is the code i have done. but not working, displaying error undefined index QRfj1VCg16Y.

   <iframe width="580" height="360" src='https://www.youtube.com/embed/{{$movie['QRfj1VCg16Y']}}'> 
    </iframe>
Mahamoud Mahamed
  • 181
  • 2
  • 4
  • 15
  • 1
    The error is pretty self-explanatory... Your `$movie` variable does not have an index `'QRfj1VCg16Y'`. – Tim Lewis Jan 13 '21 at 20:49
  • @TimLewis i know but that video id is in $movie variable array. but when i concatenate in the iframe it is not working. – Mahamoud Mahamed Jan 13 '21 at 21:02
  • *"that video id is in $movie variable array"* - No, it isn't, read your error: **Undefined index**. Do a `dd(isset($movie['QRfj1VCg16Y']))`, it'll say `false`. – Tim Lewis Jan 13 '21 at 21:09

2 Answers2

1

QRfj1VCg16Y is the id of the video, not an index of your array:

<iframe width="580" height="360" src='https://www.youtube.com/embed/QRfj1VCg16Y'> 
</iframe>
Joundill
  • 6,828
  • 12
  • 36
  • 50
-1

yeah. i found the solution i was inserting the actual video id not the index the api iam consuming says like this

"yt_trailer_code" => "QRfj1VCg16Y"

so the actual id is

$movie['yt_trailer_code']

that was easy. i donot know what was wrong with me

Mahamoud Mahamed
  • 181
  • 2
  • 4
  • 15