0
{"profilepic":"gun.jpg","0":"gun.jpg"}

Simple question. In this string i only want the gun.jpg. It also needs to be able to take other image file names. Im not really the best at php.

I would appriciate some help.

  • That's JSON. Decode it, get the value from the resulting array – brombeer May 13 '22 at 13:05
  • I converted the results of an array i got from an sql question into JSON to get the image name. I dont really know much about JSON. @MarkusZeller – Slynmannen May 13 '22 at 13:13
  • Now would be a great time to learn, then. Here's another useful resource: [How to extract and access data from JSON with PHP?](https://stackoverflow.com/questions/29308898/how-to-extract-and-access-data-from-json-with-php) – ADyson May 13 '22 at 13:14
  • I was hoping to just substring this in some way. – Slynmannen May 13 '22 at 13:15
  • 1
    Alternatively, if you previously had a PHP array and you want a value from it, you could just access that value directly. There may be no need to turn it into JSON and back again. That's generally useful if you need to store the data, or transmit it somewhere else. We are lacking context a bit, though. – ADyson May 13 '22 at 13:15
  • `I was hoping to just substring this in some way`...that isn't going to work reliably. Learn to work _with_ the structure of the data, not against it! Getting the result by decoding the JSON is super-simple though - demo: https://3v4l.org/Q1JYZ – ADyson May 13 '22 at 13:16

0 Answers0