Jump to content

Passing array Through URL!!!!!!!!


LOSTBOY

Recommended Posts

you turn your array into a string with seperator character of your choice, lets say -

you pass it to the other page with post or get

you make the string array again with explode() for example $arrayAgain = explode("-",$stringFromPostorGet);

 

so. if you want to print an element you say echo $arrayAgain[0];

to print the first value..

sorry had to go it my birthday i will continue soon..

<?php

// this is a simple array the array starts from 0 not 1 so one is at 0 and two at one.......
$my_array1=array("one","two","three");

// to walk throm a array you use the function foreach......

foreach($my_array1 as $value){

echo "<br>$value<br>";

}

//This will show all what in the array one two three


// also to see the postion of the array's order you use foreach with key added agin like so.......
$my_array2=array("one","two","three");


foreach($my_array2 as $key => $val){

echo " <br>$key $val <br>";

}


//This will show all what in the array 0 one 1 two 3 three


//also now let use another method to get the array values using implode function..

$my_array3=array("one","two","three");


$val=implode(' ',$my_array3);

echo $val;

// the result is one two three


?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.