php json array data in javascript

Solution:
Firstly, the Javascriptalert()
function is pretty basic; it can only deal with string input. If you give it an object or an array, it will choke. You're giving it objects, so it is showing you that fact in the best way it can.
If you really want to see what thedata
variable contains, I recommend using the browser's debugging tools rather thanalert()
. All modern browsers have aconsole.log()
function, which outputs your debug data to the debugging console rather than an alert box. This will give you much more useful info. Press F12 to get the debugging panel in any browser.
But my guess is that you aren't intending to output an arry ofSPLFileInfo
objects. It looks like you're probably intending to send an array of filenames.
The iterators you're using for the loop produce anSPLFileInfo
object, not simply the filename.
To get just the filename, you would use thegetFilename()
method, like so:
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator('/var/www/scripts')) as $fileinfo)
{
array_push($arr,$fileinfo->getFilename());
}
This will now generate an array of filenames, which I think is what you want.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: failed to create image decoder with message 'unimplemented'
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.