Skip to content
Advertisement

How to display the first image name from a string of image names

This is my array. I want to print the first image name from the key [image_names]

JavaScript

I tried the following code but its not working

JavaScript

Advertisement

Answer

  • There’s no space in the seperator
  • No need to quote the search string
  • Since explode(), returns an array you’ll need the first entry to get the image string [0]

Please take a close look at explode docs

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement