I have a php file list.php
<?php
$arr=array('444','555');
echo var_export($arr);
?>
Now I want to get the array from another php script using file_get_contents.
how can be this achieved ? I dont want to use sessions. The two scripts are on different servers.
You can either
serialize()the array or usejson_encode()to encode the array in JSON. Then, in the other PHP script, you would useunserialize()orjson_decode()to get the string back into an array.Example, using
serialize():In a.php (on server A)
In b.php (on server B)
You can also output the string from a PHP script, instead of saving it to a file, like so:
In a.php (on server A)
In b.php (on server B)