abrad1212 abrad1212 - 1 year ago 104
PHP Question

PHP How can I store variables in an array and call them

Ok so yesterday I was working on a PHP API all day (2:30PM - 3:30AM CT).
The user/client/front end of the API can submit a filename or link to the API so it can view it, edit it, or delete it.

But that's a problem because if the user can do that that means they could edit or delete the website with the client.

So I'm wondering can I store a bunch of variables that are equal to links, so when the client submits, the API will see if that link is unauthorized or authorized

Could you do it like this

$myArray = array( //Unauthorized Links
$link1 => "http://example.com" //First Link

Then check the links using $myArray?

If you need the API code I'll provide it.

Answer Source

use this code and it will work for you

    $myArray = array(
        1 => 'http://example-1.com',
        2 => 'http://example-2.com',
        3 => 'http://example-3.com',
        4 => 'http://example-4.com'

    foreach($myArray as $key => $value){
        echo 'link '.$key.' = '.$value.' <br>';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download