Suggested way to allow others to plugin to my php script and change variable values?
<p>People want to use my Jquery plugin, but get a list of images from a database instead of a directory, which is the standard way the plugin works.</p>

<p>My Jquery plugin that uses the ajax() function to deliver &amp; return data to a php script.</p>

<p>The php script pulls files from a directory with getdir(), adds those files to an array and assigns that array to a variable.</p>

<p>People have requested the ability to create that variable value themselves by generating it from a database (not just pulling files from a directory using scandir).</p>

<p>What is a good, secure way to do to allow others to replace a variable value inside my php script?</p>

<p>Ideally, I would like there to be a way where users can create their own script in a separate document (and they don't need to alter my document).</p>

<p>Here is a simplified example of my script:</p>

<p>HTML Document</p>

<pre><code>&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt;
 &lt;script&gt;
$.ajax({
    type: "POST",
    url: "example.php",
    cache: false,
    data: {
        foo: "some_directory",
            },
    success: function(html){
    alert(html);
    }
});
&lt;/script&gt;
</code></pre>

<p>PHP Document</p>

<pre><code>&lt;?php

$foo = $_POST["foo"];
$foo = scandir($foo);
$foo = (explode(",",$foo)); // how can I allow others to change this variable value?
foreach ($foo as $a) {
    echo "&lt;p&gt;$a&lt;/p&gt;";
}

?&gt;
</code></pre>
