page1.php
$destinationCity = $_POST['destination'];
$sr = new searchArray();
$final = $sr->searcharray($destinationCity);
echo "<pre>";
print_r($final);
echo $final->vc[0];
echo "</pre>";
Page2.php
class searchArray {
public function searcharray($arr) {
$rst = array();
$length = strlen($arr);
if ($length == 2){
$sql = "select code from ukhotels where postcode LIKE '$arr%'";
$rsd = mysql_query($sql);
while($rs = mysql_fetch_array($rsd)){
$co = $rs['code'];
$vc = &$rst['vc'];
$vi = &$rst['vi'];
$vc[] = substr($co, 0, 2);
$vi[] = substr($co, 3, strlen($co));
}
}
In page1 i am calling the function with one argument. In the page2 i am keeping the results in an associate array.
When I am printing the array from page1 its showing me output as
Array
(
[vc] => Array
(
[0] => CB
[1] => RD
[2] => RT
[3] => YX
)
[vi] => Array
(
[0] => 01461
[1] => 95101
[2] => 30818
[3] => 77126
)
)
i wanted to use the array in page1 like this
for($i=0, $j=1;$i<=20;$i++)
{
$params["VendorLocation"]["VendorCode"] = "{$final->vc[$i]}";
$params["VendorLocation"]["VendorLocationID"] = "{$final->vi[$i]}";
$params["VendorLocation"]["Key"] = "{$j}";
$j++;
}
but it is throwing me an error saying " Notice: Trying to get property of non-object "
Can any one please help me how to solve this issues.
Regards Hailey