PHP - Visibility/scope Of Variables And Functions
I have some questions about the scope of navigation :
if i define a constant like define('constant'), php manuel says it's global, does this mean that i can use of different files also? like, i defined in define.php and used in anotherfile.php, or shoud the latter file be included then? what about file a.php includes file b.php which in turn includes file c.php. Can functions of a use variables of file c? ultimately: what about variables that are declared global inside a function but this variables is not initialized in that script, like in wordpress: function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) { global $wp_locale; // more code } $wp_locale can be initialized in another script file? thanks in advance Similar TutorialsI know this is a simple question, but it's been bugging the hell out of me. i am being told that i have an undefined variable - errorString - in a function, even though it *clearly* is defined w/i the scope of the function. Can somebody please help me out? Code: [Select] [Undefined variable: errorString/code] [php] /** * is fed a string email address and processes it to make sure that we're within limits: * * 1) must not be empty * 2) must not be above 50 characters * 3) must be in name@example.tld format * * returns TRUE if email is valid, string (with reasons for failure) if the email is not valid * * @param string $email * @return boolean|string */ public static function data_validateEmail($email){ // set up temporary vaiable $errorString; // check to see if the user's email is a null string if (empty($email)){ $errorString .="You must supply an email address. "; } // then check to see if its under 50 characters if(strlen($email) > 50){ $errorString .= "The email address can be no longer than 50 characters. "; } // then make sure it's in teh correct format if (!preg_match('/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i', $email)) { $errorString .= "The email address must be in the name@domain.tld format. "; } // if we've got a valid email, return true... else, we return a string error if(empty($errorString)){ return true; } else { return $errorString; } } [/php] errorString is defined at the beginning of the function, so why am i told that it is undefined when, say, the length test fails? I know this has to be a simple solution, but ive spent almost 2 hours looking at it trying to figure it out, and have gotten nowhere.... :( and yes, part of that 2 hours was searching google for information about how PHP does variable scope in functions with multiple if statements... and all i could find was that as long as the variable is defined in the function scope, it should be available within the successive if statements. Thanks for reading! I need a bit of help understanding the scope of variables If I have the following code: Code: [Select] <?php $myvar = true; include(otherfile.php); ?> Is $myvar available for access as is in the code from otherfile.php? Specifically though, I'm trying to get my head round some Wordpress coding, so I have this instead: Code: [Select] <?php $myvar = true; <?php get_header(); ?> ?> <?php get_header(); ?> puts the contents of header.php at this location + I'm sure it does some other things like error checking etc What is the best way to have $myvar available? The ONLY thing is I only want $myvar = true just for one file - everywhere else it should be false or not exist I'm wary of using a global variable - but if it's the only way, then I have to Thanks Omar Hello all, I have a 14 column csv that I load into an array, retrieving only the required fields, load the array into columns and perform a sort: Code: [Select] foreach ($array as $key => $row) { $firstname[$key] = $row["firstn"]; $lastname[$key] = $row["lastn"]; $address1[$key] = $row["addr1"]; $address2[$key] = $row["addr2"]; $address3[$key] = $row["addr3"]; $city[$key] = $row["cit"]; $stateprov[$key] = $row["state"]; $country[$key] = $row["cntry"]; $membernumber[$key] = $row["num"];} array_multisort($membernumber,$lastname,$firstname,$address1,$address2,$address3,$city,$stateprov,$country,$array);When I pass say the first three letters of a last name ($find = "smi"), all records matching the search criteria are returned: Code: [Select] foreach ($array as $key => $row) { if (strncasecmp($find, $lastname[$key], strlen($find)) == 0) { echo "<tr><td>" . $firstname[$key] . "</td>"; echo "<td>" . $lastname[$key] . "</td>"; echo "<td>" . $address1[$key] . "</td>"; echo "<td>" . $address2[$key] . "</td>"; echo "<td>" . $address3[$key] . "</td>"; echo "<td>" . $city[$key] . "</td>"; echo "<td>" . $stateprov[$key] . "</td>"; echo "<td>" . $country[$key] . "</td>"; echo "<td>" . $membernumber[$key] . "</td></tr>" . chr(13); }}}So far so good. However, I'd like to put the search part into a function so I can call it a number of times without having to reload the entire csv: Code: [Select] function FindMember() { foreach ($array as $key => $row) { if (strncasecmp($find, $membernumber[$key], strlen($find)) == 0) { echo "<tr><td>" . $firstname[$key] . "</td>"; echo "<td>" . $lastname[$key] . "</td>"; echo "<td>" . $address1[$key] . "</td>"; echo "<td>" . $address2[$key] . "</td>"; echo "<td>" . $address3[$key] . "</td>"; echo "<td>" . $city[$key] . "</td>"; echo "<td>" . $stateprov[$key] . "</td>"; echo "<td>" . $country[$key] . "</td>"; echo "<td align='right'>" . $membernumber[$key] . "</td></tr>" . chr(13); }}}}The search criteria would come from a second txt file with every line containing 2 numbers, separated by a comma: Code: [Select] foreach ($lines as $member => $numbers) { $exploded = explode(",", $numbers); $find = $exploded[1]; FindMember();here $exploded[1] corresponds to $membernumber[$key], so this is where I would call the function, but this is where I run into trouble, nothing gets returned. Does this have something to do with the scope of variables inside a user-defined function? I'd appreciate it if someone could point me in the right direction. TIA I have a database that holds a list of companies. the database includes and ID, and name of each company. Now when an articles gets submitted to my site it can then be related to company. We a relate a company to an article its related through its ID. What I want to do is create a function that would let me easly convert my company ID into company name within having to write out the queries over and over again in my code. Only problem is I can't get it to work. I have two files, index.php and functions.php. functions.php Code: [Select] function cname($pubid) { global $db; $company= $db->query("SELECT * FROM my_database WHERE id='$pubid'") or die(mysql_error()); while($company= $db->fetch_array($company)) { $cname = $company['name']; } return $cname; } and within index.php I put Code: [Select] echo cname($companyID); Now, when I first looked at index.php I was getting an error. I know it had something to do with me using my variables within the function and after some searching I ended up getting rid of the error by adding "global $db;" to my code. Please note that I include functions.php at the top of index.php. What am I doing wrong and why wont it work? HELP PLEASE! also note that my i've rechecked and all the database info is correct and names spelt right. Just dont know what else to do. I've written the following code: Code: [Select] $mode = 'development'; // 'Development' or 'Public' // Writes a buffer to a file /** * ob_file_callback() * Writes the generated CSS to a file. * @param mixed $buffer * @return void */ function ob_file_callback($buffer) { // stylesheet-public.css is the output generated file $ob_file = fopen('stylesheet-' . $mode . '.css','w'); fwrite($ob_file, $buffer); } $buffer = 'test'; ob_start('ob_file_callback'); $mode is always empty when I run this code. Is it an issue because ob_file_callback is an overridden function? Still working on my project, and i have been learning a lot here! Thank you so much. But as you may have guessed, i still have problems. User registration is working, and new users are put in the database with a rank of 0. This means they can't do anything. (can there be trouble with this. I mean, a rank of "0"?) An admin needs to give access to these accounts, but that is where it becomes difficult. The following code is showing the new accounts to the admin. Code: [Select] <?php include("navbar.php"); if ($admin<2) //normal guy or not { die ("Du har ikke rettigheder til at se denne side!"); } else if(isset($_POST['submit'])) { //code to make the user able to use stuff } { $connect = mysql_connect("localhost","root",""); mysql_select_db("eksamen - phoenix"); $query = mysql_query("SELECT * FROM users WHERE rank='0'"); ?> <form action='admin.php' method='POST'> <table> <?php while($row = mysql_fetch_assoc($query)) { echo " <tr> <td> ".$row['username']." </td> <td> ".$row['email']." </td> <td> ".$row['real_name']." </td> <td> <input type=\"checkbox\" name=".$row['username']." value=\"Godkend\"> </td> </tr> ";} ?> <tr> <td> <input type='submit' name='submit' value='Register'> </td> </tr> </table> </form> <?php } ?> As you may see, there is a lot of turning php on and off. I made it work this way, but i guess there is nothing wrong with it. The problem is that the username is not stored, so i can connect to the database and change the "rank" value. Changing that value should be easy, but storing the username is as easy as i thought. Any ideas? I have this function: Code: [Select] function echo_exist($pre1,$ee,$post1) { if ($ee!='') { return $pre1; return $ee; return $post1; } else { //do nothing } } But when I try to echo it Code: [Select] echo_exist("(","$row['payment_type']",")"); I get syntax error, unexpected T_ENCAPSED_AND_WHITESPACE If $row['payment_type'] exists, I want it to be displayed in parentheses like: (AUTO) I suspect it has to do with my ' characters for the associative array, but I am new with functions so perhaps it is the multiple arguments that are wrong? I think I need to use $this, but I need to be able to add the two values returned from both of my functions. How would I do that? Code: [Select] public function get_users_edge($uid) { $users_primary->get_users_primary_edge($uid); $users_dynamic->get_users_dynamic_edge($uid); echo $users_primary + $users_dynamic; } I have a little problem. I have made a script(function) to connect to the database. this is the script: connect(php) Code: [Select] <?php $server = "localhost"; $username = "username"; $password = "password"; function connectdatabase($type,$database) { if($type == "mysql") { $mysql = mysql_connect($server, $username, $password); mysql_select_db($database, $mysql); } else if($type == "mysqli") { $mysqli = new mysqli($server, $username, $password, $database); } else if($type == "mssql") { $mssql = mssql_connect($server, $username, $password); mssql_select_db($database, $mssql); } function query($query) { if($type == "mysql") { mysql_query($query); } else if($type == "mysqli") { $mysqli->query($query); } else if($type == "mssql") { mssql_query($query); } } } ?> and aanmelden(php) Code: [Select] <?php include("config.php"); connectdatabase("mysql", "[ledensysteem]"); //example if(!empty($_POST)) { if(!preg_match('/^[A-Za-z1-9-]{'.$Minimale_Gebruikersnaam_Karakters.',}$/', $_POST['gebruikersnaam'])) { if(!isset($error)){ $error=1;}else{$error=$error+1;} echo "Je gebruikersnaam moet minimaal {$Minimale_Gebruikersnaam_Karakters} tekens bevaten en mag geen komma of andere onbedoelde tekens zijn<br>Toegestaan is <br>A t/m Z <br>a t/m z <br>1 t/m 9 <br>en -"; } else { echo "geldige gebruikersnaam(goedgekeurd)"; } if(preg_match('/^[A-Za-z1-9-]{'.$Minimale_Wachtwoord_Karakters.',}$/', $_POST['wachtwoord']) && preg_match('/^[A-Za-z1-9-]{'.$Minimale_Wachtwoord_Karakters.',}$/', $_POST['herhaalwachtwoord'])) { if($_POST['wachtwoord'] != $_POST['herhaalwachtwoord']) { if(!isset($error)){ $error=1;}else{$error=$error+1;} echo "niet hetzelfde wachtwoord"; } /*else { echo "hetzelfde wachtwoord (goedgekeurd)"; }*/ } else { if(!isset($error)){ $error=1;}else{$error=$error+1;} echo "wachtwoord moet minimaal {$Minimale_Wachtwoord_Karakters} tekens bevatten!"; } if(!preg_match("/^[A-Za-z1-9_.-]{1,}@[A-Za-z1-9-]{1,}\.[A-Za-z1-9]{2,3}$/", $_POST['email'])) { if(!isset($error)){ $error=1;}else{$error=$error+1;} echo "onjuiste email"; } else { echo "goedgekeurd!"; } if(!isset($error)) // this problem is fixed yesterday on phpfreaks.com forum! { echo "goedgedaan geen errors!"; query("SELECT username FROM phpfreaks WHERE password = private"); // example } } else { ?> <HTML> <HEAD> <TITLE>New Document</TITLE> </HEAD> <BODY> <form method="post"> <input type="text" name="gebruikersnaam" value="gebruikersnaam" maxlength="20" size="20"> <input type="password" name="wachtwoord" value="wachtwoord" maxlength="20" size="20"> <input type="password" name="herhaalwachtwoord" value="herhaalwachtwoord" maxlength="20" size="20"> <input type="text" name="email" value="voorbeeld@domeinnaam.extensie" maxlength="50" size="20"> <input type="submit" name="login" value="inloggen"> </form> </BODY> </HTML> <?php } ?> the problem is, is that i want to pass a variable between functions like $type (the database type) between connectdatabase(); and query(); in the 'aanmelden.php' file is an example of how i use the function (on line 3 and 45 the ones with //example comment) thanks for reading. please help. ps. config.php contains include("connect.php"); Learning something new here so if anyone can tell me why I this wont return a value? page1.php Code: [Select] <?php require "page2.php"; getuserid(); echo $userID; ?> page2.php Code: [Select] <?php function getuserid() { $user =& JFactory::getUser(); $userID = $user->id; global $userID; } ?> Hi, In all my classes, I need to declare globals for everything else, from site variables even to objects (other classes). I obviously don't want to as globals are horrible and I need to have functions clean without globals. I have included a list of all the global vars in the construct and it still doesn't work. Example: start.php <?php $vars = array(some values); $some = more; $variables = foo; $helper = new Helper(); $home = new Home(); This is a little bit simplistic, but for some reason, the variables just don't want to go in the main class without a global. Functions will not run if they require any of these variables. Hi Guys
I have a question about maintaining scope in OOP. I may just be going about it in completely the wrong way but I'm here to learn.
Lets say I have a base class called 'first; set out as per the code below.
In the first class there is a method that instantiates another class - called second. This second class extends the first class and I want it to be able to set errors on the first class. The only way I can maintain it's scope is to pass $this into the constructor of the second class.
My questions a
1) Is this the right way to maintain scope?
2) Would this be bad practice and I should explore a different model for setting out these classes?
3) Would it be considered better practice to make $errors a static property?
Keen to do things the right way so any advice is very welcome
class first { public $errors = array(); public function __construct(){ $this->callSecondClass(); $this->render(); } public function callSecondClass(){ $t = new second($this); } public function render(){ echo "I am rendering errors:"; print_r($this->errors); } } class second extends first { public function __construct($obj){ $obj->errors[] = 'ERROR FROM SECOND CLASS'; } } Edited by Drongo_III, 14 August 2014 - 04:54 PM. I just have a quick question, what happens if I don't assign a visibility element to methods? In other words, if I just have: [php] class Article_model { public $data; function index() { return $data; } [php] ...instead of declaring public, private, static, and so on before the function. Will php just consider it public? Hey Guys. I am trying to assign a property through a method that is called in a swtich method.
After the property gets "assigned" I do a var_dump on the property and it returns NULL?
I am not sure why it returns NULL.... I would really appreciate any help...
class Tea { public $current_tea; //Current tea does not get assigned when using the AssignTea($TeaArg) function private $upcoming_tea = "Blacktea"; public function SelectTea() { $TeaType = "Black"; switch ($TeaType) { case "Black": $this->AssignTea($this->upcoming_tea); break; }// End of Swtich }// End of function SelectTea() private function AssignTea($TeaArg){ $this->current_tea = $TeaArg; } } $tea = new Tea(); var_dump($tea->current_tea); Edited by eldan88, 20 May 2014 - 10:07 AM. I have a script I am putting together that simulate a cricket game. The only issue is, that there are a huge number of functions because there doesn't seem to be any other way to do this properly. As well as this, there a while() loop and all this seems to be leading to the page reaching a max 30 second timeout when generating the result. My code is attached below, it is quite messy at the moment because i've just be working on it, but I was wondering if anyone has any solutions of how I can speed this up or change to prevent a timeout: <?php // Error reporting error_reporting(E_ALL); // Connect DB mysql_connect("wickettowicket.adminfuel.com", "rockinaway", "preetha6488") or die(mysql_error()); // Select DB mysql_select_db("wickettowicket") or die(mysql_error()); // MySQL queries to find batsmen and bowlers $array_batsmen = mysql_query('SELECT id, name, ability, strength FROM wtw_players WHERE team_id = 1 ORDER BY id ASC'); $array_bowlers = mysql_query('SELECT id, name, ability, strength FROM wtw_players WHERE team_id = 2'); // Start table for data $data = '<table width="600px">'; // Create blank scorecard while ($array_bat = mysql_fetch_array($array_batsmen)) { $data .= '<tr><td>'.$array_bat['name'].'</td><td></td><td></td><td>0</td></tr>'; } // Set up arrays for players $current_batsman = $current_bowler = array(); // Reset query mysql_data_seek($array_batsmen,0); $in_one = $in_two = $it = ''; function currentBatsman($id, $name, $ability, $strength, $out, $in, $runs) { global $current_batsman; $current_batsman = array ( 'id' => $id, 'name' => $name, 'ability' => $ability, 'strength' => $strength, 'out' => $out, 'in' => $in, 'runs' => $runs ); echo 'set current'; } // Set up arrays of batsmen while ($array = mysql_fetch_array($array_batsmen)) { if ($it < 3 && $in_one == '') { currentBatsman($array['id'], $array['name'], $array['ability'], $array['strength'], 0, 1, 0); $batsmen[$array['id']] = array ( 'id' => $array['id'], 'name' => $array['name'], 'ability' => $array['ability'], 'strength' => $array['strength'], 'out' => 0, 'in' => 1, 'runs' => 0 ); $in_one = $array['id']; $current = $array['id']; $it++; } else if ($it < 3 && $in_two == '') { $batsmen[$array['id']] = array ( 'id' => $array['id'], 'name' => $array['name'], 'ability' => $array['ability'], 'strength' => $array['strength'], 'out' => 0, 'in' => 1, 'runs' => 0 ); $in_two = $array['id']; $it++; } else { $batsmen[$array['id']] = array ( 'id' => $array['id'], 'name' => $array['name'], 'ability' => $array['ability'], 'strength' => $array['strength'], 'out' => 0, 'in' => 0, 'runs' => 0 ); } } // Bowler Array while ($array = mysql_fetch_array($array_bowlers)) { $bowlers[] = array ( 'name' => $array['name'], 'ability' => $array['ability'], 'strength' => $array['strength'] ); } // Reset both queries mysql_data_seek($array_bowlers,0); mysql_data_seek($array_batsmen,0); function changeBatsman($just_out) { global $array_batsmen, $batsmen; //Update array $batsmen[$just_out] = array ( 'in' => 1, 'out' => 1 ); while ($array = mysql_fetch_array($array_batsmen)) { if ($just_out != $array['id'] && $batsmen[$array['id']]['out'] != 0) currentBatsman($array['id'], $array['name'], $array['ability'], $array['strength'], 0, 1, 0); } // Reset query mysql_data_seek($array_batsmen,0); echo 'change batsman'; } function swapBatsman($other_batsman) { global $array_batsmen, $batsman; while ($array = mysql_fetch_array($array_batsmen)) { if ($other_batsman != $array['id'] && $batsman[$array['id']]['out'] != 0 && $batsman[$array['id']]['in'] == 1) currentBatsman($array['id'], $array['name'], $array['ability'], $array['strength'], 0, 1, 0); } // Reset query mysql_data_seek($array_batsmen,0); echo 'swap batsman'; } $runs = $outs = $balls = $overs = 0; $played = array(); function selectBowler() { global $bowlers, $current_bowler; // Select random bowler $choose_bowler = array_rand($bowlers, 1); $current_bowler = array ( 'name' => $bowlers[$choose_bowler]['name'], 'ability' => $bowlers[$choose_bowler]['ability'], 'strength' => $bowlers[$choose_bowler]['strength'] ); } /* function selectBatsman(); { global $array_batsmen; while ($array_batsmen[]['out'] != 1) { }*/ function bowl() { global $batsmen, $bowlers, $current_bowler, $current_batsman, $data, $balls, $outs, $runs; if ($current_batsman['out'] == 0) { echo 'bowling'; // Set the initial number $number = rand(0, 190); // Ability of batsman if ($current_batsman['ability'] > 90) $number += 30; else if ($current_batsman['ability'] > 70) $number += 15; else if ($current_batsman['ability'] > 50) $number += 2; else $number = $number; // Strength of batsman if ($current_batsman['strength'] > 90) $number += 15; else if ($current_batsman['strength'] > 70) $number += 10; else if ($current_batsman['strength'] > 50) $number += 5; else $number = $number; // Depending on overs if ($balls > 270) $number += 30; else if ($balls > 120) $number -= 10; // Ability if ($current_bowler['ability'] > 90) $number -= 30; else if ($current_bowler['ability'] > 70) $number -= 15; else if ($current_bowler['ability'] > 50) $number -= 2; else $number = $number; // If batsman has made a huge total of runs, we need to knock some numbers off - more likely to get out if ($current_batsman['runs'] > 200) $number -= 70; else if ($current_batsman['runs'] > 100) $number -= 30; // Finally sort out runs if ($number > 190) $run = 6; else if ($number > 170) $run = 4; else if ($number > 160) $run = 3; else if ($number > 100) $run = 2; else if ($number > 50) $run = 1; else if ($number > 10) $run = 0; else if ($balls > 120 && $number > 0) $run = 0; else $run = -1; // Increase number of balls $balls += 1; // Are they out? if ($run == -1) { $current_batsman['out'] = 1; $played[] = $current_batsman['id']; $find = '<tr><td>'.$current_batsman['name'].'</td><td></td><td></td><td>0</td></tr>'; $replace = '<tr><td>'.$current_batsman['name'].'</td><td></td><td>'.$current_bowler['name'].'</td><td>'.$current_batsman['runs'].'</td></tr>'; $data = str_replace($find, $replace, $data); changeBatsman($current_batsman['id']); echo 'out'; } else { $current_batsman['runs'] += $run; $runs += $run; if ($run == 1 || $run == 3) { swapBatsman($current_batsman['id']); echo 'time to swap'; } echo $run; } // Count outs if ($current_batsman['out'] == 1) $outs += 1; } } function game() { global $main, $batsmen, $bowlers, $data, $batted, $balls, $outs, $current_batsman; // Check if possible while ($balls <= 295 && $outs < 10) { selectBowler(); // Actually bowl now bowl(); } } game(); echo $data; First: i'm pretty new to PHP. Second, the situation: i've got a array of universities. Each university within the array, which is also an array has values like an ID and Name. I wan't to add a value to that university from a xml feed, a URL. I can match ID's to find the corresponding university in the xml feed. Third, my question: Why do i lose the ['hURL'] outside of my foreach loop(s) ? It's working inside the foreach loop ... Fourth, here's the code: Code: [Select] $hDirectory = get_xml_feed('http://myawesomefeed.xml'); $universiteiten = array( $uniUtrecht = array('uniNaam' =>'Universiteit Utrecht', 'uniID' => 'uu'), $uniWageningen = array('uniNaam' =>'Wageningen University', 'uniID' => 'wur') ); foreach( $universiteiten as $universiteit ) { echo '<strong>' . $universiteit['uniNaam'] . ':' . '</strong> <br />'; foreach( $hDirectory->Entity as $school ) { if ( $universiteit['uniID'] == $school->orgUnitId ) { $hURL = (string) $school->DirectoryURL; $universiteit['uniURL'] = $hURL; echo 'Universiteit ID: ' . $universiteit['uniID'] . '<br />'; echo 'Hodex URL: ' . $universiteit['hURL'] . '<br /><br />'; //this works just fine } } } echo '<br/>'; print_r_html($uniUtrecht); // but here the [hURL] is missing I have an HTML form with a Dropdown list off dates. The Dropdown is populated using PHP and an array... Code: [Select] <?php $concertDates = array('201105071'=>'May 7, 2011 (9:00am - 12:00pm)', '201105072'=>'May 7, 2011 (1:00pm - 4:00pm)', '201105141'=>'May 14, 2011 (9:00am - 12:00pm)'); ?> When my HTML form is re-submitted to itself, what happens to $concertDates?? I was under the impression that it remains alive as long as my script is running... Debbie In this code... class Model { public function getBook($title) { $allBooks = $this->getBookList(); return $allBooks[$title]; } } Questions: --------------- 1.) What is the scope of $allBooks? Can it be seen outside the function and inside the class? 2.) Could I rewrite things like this... Quote class Model { protected $allBooks; public function getBook($title) { $allBooks = $this->getBookList(); $this->allBooks = $this->getBookList(); return $allBooks[$title]; } } 3.) Sorta off-topic, but could I rewrite this code... Quote $allBooks = $this->getBookList(); return $allBooks[$title]; like this... Quote return $allBooks = $this->getBookList([$title]); TomTees is there a way of having set variables for a specific include?...maybe be easier for me to explain via code
<?php $bee = 'yes'; include_one "a.php"; include_one "b.php"; // only b.php can grab $bee var ?>im wondering if I can only pass a var to b.php without a.php being able to use the var also? thanks guys i have a text box, the no of text boxes that are displayed are random depending upon the condition of the loop.. hosting[] takes up many no of values <input type='text' name='hosting[]' size='2' /> when the form is submitted i use the following code to access the content of hosting[] $link_no = $_POST['hosting']; $total_actual_links = null; foreach($link_no as $total_link) { $total_actual_links[] = $total_link; } now i get the results in $total_actual_links[].. i want to pass the value of this array into the value of another text box of other form which i get on submission of the 1st form.. i do not knw how shud i do this.. please help |