Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




How Do You Pass Functions Via Arrays Into Loops?


How do I pass a function through an array into a loop? I'll explain what I mean. I have a function (do_telcos) which just grabs a list of Telephone companies and their IDs and spits them into a dropdown box. I'm trying to use this in a form that I'm building from an array as follows: Code:




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Loops And Arrays?
Does anyone know where an in depth tutorial is to learn about loops and arrays? One that will give good examples.

Objects, Arrays, And Loops
I'm working on an auto-schedular for my college's Music Festivals. I just started on this tonight. I'm starting by reading all the information into variables. For starters, I have a School class. The script should read data from the database into School objects for later use. I've never used objects in PHP before, but I've used them in several other languages. I read data from the database into the School objects using a loop, with a loop invariant
called $schoolCount. I created a print statement so that I could see
if the data was being correctly assigned to the School objects, but I
think it's printing the value of the loop invariant instead of the
school name like I want. I'm not sure why. Here's my code:

Associative Arrays And Loops
I am trying to make database calls on what will potentially be a very large database. I would like to receive query results from the database using mysql_fetch_array() to get an associative array.

Once I have this array, I want to show certain fields using my own formatting.  If there are no fields, I want to show a "No Results" message. My code thusfar looks like this, and it does nothing if there is an invalid database query: Code:

Pass Variables To Functions
In php i've found that I cant seem to access global variables from within a function. Is there a way to access variables in a function that are in the same scope that the function is??? Can you make a variable global or something? How does that all work in PHP, is there a doc somewhere to explain? Can I define a global within a function in php?

Pass Values Of Arrays To A New Page
How do i pass all the values onto another page that I have gathered. If I have a form and place info into the array, how do I pass the value in that array over to a new page.

Arrays, Functions
I know this has been covered, because I've been reading everything I can on the subject, but I can't seem to figure out how to pass arrays into and out of my functions. PHP Code:

Passing Arrays To Functions
[code]
$job_status = array(
"unassigned",
"current",
"completed"
);

function gimme($name){
echo $$name; // this is in hopes to echo the contents of $job_status when gimme(job_status) is called
}

How can I get $name to be the ARRAY $job_status? I'm trying to keep this very modular so that I can also perform:

gimme(job_type); among others.

Question About Arrays And Functions
$sql = "DELETE FROM " . $mosConfig_dbprefix . "foo WHERE foo_id = '" .
mosGetParam($_POST, 'cid', '' )[$a] . "'";

was throwing errors and I fixed it be doing this:

$cidx = mosGetParam( $_POST, 'cid', '' );
$sql = "DELETE FROM " . $mosConfig_dbprefix . "foo WHERE foo_id = '" .
$cidx[$a] . "'";

My question is why didn't the first version work and is there a way to
code it without adding the intermediate variable?

Passing Arrays To Functions
How do I pass an array to a function? This is what I have, and the second
function doesn't seem to be getting the array somehow. I'm sure it's in
the function declaration...

function one(){
return $array; // yes, there is more to this function, and assume that
"$array" is a real array
}

funtcion two($arrayArg){ // <- I'm sure the prob is here.
print_r($arrayArg); // This isn't printing anything, when it does in one()
}

then I call:
two(one());

Once again, I'm sure the prob is in the declaration.

Arrays And While Mysql Functions
How can I get this array to work? I am trying to add data to an array for every row of data? This is a sellection of queries that I need to parse into an array so a function can use the arra to draw a graph. I am new to arrays how can I get this to work? Code:

Elements From Functions That Return Arrays
I'd like to access a single element from a function that returns an
array; and I'd like to do it in a single statement.

Here's an example. This is obvious.
$a = explode(".", "this.is.some.text");
$b = $a[2];

So how can I do that in a single statement?
$a = explode(".", "this.is.some.text")[2] // no
$a = (explode(".", "this.is.some.text"))[2] // nope
$a = [explode(".", "this.is.some.text")][2] // no way

How close am I coming to the final result. My goal is to be able to
nest them.

I was looking for an answer in the array functions, but the ones I
found don't return a scalar value, they return arrays in my cases.

Nesting Result Loops Within Result Loops Possible?
I'm looping through a query, and inside the while result output, I am trying to loop through a second query (created from the 1st query's row results).

I have checked that both queries return info.

I can see that the 1st while result output works fine, but when I get to the inner while result output, it never returns any rows (nothing in the while loop evaluates).

So, IS it possible to nest one query's output loop within another, or am I doing something wrong?

Using MD5($pass) With PHP And MD5 Tables Or Password('$pass') In SQL
My intranet log in page (which starts the session)
has a password field, and later once the form is submitted
(after all the checking) the $pass var goes through this:

$pass = MD5($pass);

And my password column has MD5 encrypted passwords.

I could just use password('$pass') in my SQL query and remove the MD5() from my PHP if I convert my column to "Password" instead of "MD5".

So which one is safer? I think MD5 is safer and is sort of a standard so my database has a little more portability if ever needed.

I have another question. My Form once submitted obviously has the non encrypted password until the variable is processed. The only way to protect this is to put the intranet on a SSL connection right?

For Loops Vs While Loops
Seems like every day I read 2-3 posts espousing the use of Foreach over While and vice versa.

Time to set the record straight...

http://www.php.lt/benchmark/phpbench.php (not my page, but it was far easier than coding it myself)

And the winner is... For loops.

There you have it. Concrete proof, instead of conjecture. For loops are faster. I guess I'll have to code up some tests to see if it's faster to grab the count from a mysql query and use a for loop vs using a while loop to iterate over a returned record set.

Feel free to comment, but please, cite refrences if you wish to contradict what I have written. I'm tired of hearing "facts" that are unsubstantiated.

Using While Loops
Does anyone know how collect user information from a database for each user, perform an operation on it, then output each user's information as a seperate variable?

I have it to the point where I set up a while loop that retrieves each user's information but I can't automate the setting of the unique variables.

Loops
Is it possible for me to create a loop which makes a form for me over and over again until it has done 30? I need this to be repeated over and over, yet everytime it increments the name. So, in this example, it would be thing then thing1 then thing2etc allthe way until thing29. Code:

Loops
I have this this code
{while ($row = mysql_fetch_array($numresultsgal)) {
$table=$row{'table_gal'};
$numresultphotos=mysql_query("SELECT * FROM" .$table. "order by date desc");
$numphotos=mysql_num_rows($numresultphotos);

echo"<b>Gallery:</b> " .$row{'gallery'}. "<br>";
echo "<b>No. Of Photos:</b> " .$numphotos. "<br>" ;}

But it keeps failing to produce the number of photos in the gallery. But it
will display the table name if i want it to. So it's got the correct name,
so any ideas why it's failing and not telling me how many rows are in the
database.

Using 2 Loops With MAX()/MIN()
I am developing a simple messageboard that will list threads. There will be the first post of the thread and directly underneath will be the last reply to that thread. My problem is that instead of the last reply, the last post in the db is being displayed under all of the threads.

actionID is the auto incremented primary key. subjectID is an integer that is the same for a post and all of its replies. A new post will have the next incremented integer. Code:

Loops
I need a loop to show the results of a message board system where $board = 1, so it shoes all the results. The current code only shows the first result.
So here is my code:

For Loops
How would I make a script using for loops to figure out this equation: EDCBA x 4 = ABCDE

Each letter represents a number and i need to know what ABCDE is. Anyone know?

Need Help W/using Loops With Templates
I'm starting to use templates for my site and was curious about how they handled loops. For example, let's say I have a HTML table like this:

<table width="750" border="0">
<tr>
<td>{ARTIST}</td>
<td>{SONG_TITLES}</td>
</tr>
<tr>
<td>{ALBUM_TITLE}</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>

And the PHP file then calls records from the database for each placeholder in a while loop like this...

$result=mysql_query("select * from music where id = '$album_id'");
while ($row = mysql_fetch_array($result))

{
$album_id=$row['album_id'];
$artist= $row['artist'];
$album_title= $row['album_title'];
$song_title=$row['song_title'];
}

Normally, I would do something like this in the php file to point the data to the placeholder....

$myTemplate->tag("Site_title",gettitle());

So...my question is...where would I place the call to the database and the while loop and point each placeholder. Would I do something like this...

getmusic();
$myTemplate->tag("Album_Title",$row['album_title']); OR
$myTemplate->tag("Album_Title",$album_title);

If anyone has experience with this, please help! Thanks!!

Mysql_data_see For For() Loops?
Am I right to say mysql_data_seek allows me to walk through a database
return as I would an array?

for ($1=0; $i < $num; $i++) {
mysql_data_see($result, $i);
$row = mysql_fetch_array($results);
}

I still haven't solved the problem I mentioned in another post (I can
only get the first row back from my returns), so I'm tempted to go
this route.

Goto Loops?
I had someone ask me this at work and I had no clue if it existed in PHP, so I'm wondering if any of you know. In most scripting languages, they have a goto command (as in mIRC) and you can specify different sections, i.e.PHP Code:

Do...while Loops Forever
While attempting to alleviate a persistent but not consistent problem
with my database operation (DB2) I coded the do...while loop around my
odbc_connect. When $dbConn is false the first time, the program never
returns. This problem repeatable with or without the @ on the
odbc_connect call. I would someone pointing out my stupidity. I did
RTFM, including the examples, and was no further enlightened. Thanks in
advance.

function conn() {
global $schema, $database;
$schema = "is3";
$database = "animalst";
$dbuser = "db2inst1";
$dbpwd = "db2rules";
$ct = 0;
do {
$dbConn = odbc_connect($database,$dbuser,$dbpwd);
$ct += 1;
if($dbConn==False) { sleep(1); }
}
while(($dbConn==False) && ($ct<5)) ;
if ( $dbConn==False) {
printf("<br>The odbc_connect parameters were:[%s] [%s]
[%s]<br>
" , $database,$dbuser,$dbpwd);
printf("<br>Tried %d times<br>
",$ct);
showerror();
die("could not connect to $database");
}
return $dbConn;
}
?

Code WHILE Loops
A script is written to query a db and print the result on the screen.

$result = mysql_query("SELECT * FROM events",$db);
$myrow = mysql_fetch_array($result);
$type = $myrow['type'];
echo "Type = $type";
while ($myrow = mysql_fetch_array($result)
{
$type = $myrow['type'];
echo "Type = $type";}

Question: Is there a cleaner way of coding this loop (which works fine, btw)?

If I don't include the first fetch_array & echo statement, the first row of the table is not printed to the screen. Using: while ($result) makes an endless loop (gets stuck on the first record). Same thing for while ($myrow). I don't mind coding it like my example above, but it seems like this is a convoluted way of doing things.

WHILE Loops Twice, Only Want It To Loop Once...
I have a working script, but for some annoying reason, this script for counting attendance over time for a single member loops through the years twice...any idea why?:
PHP Code:

Queries Outside Loops?
It was suggested to me that to speed up some code I have for a multiple select box that I place my queries outside my loops. I can't say I have the foggiest clue on how to do that.
My original code looked like: PHP Code:

Forms + While Loops
i have a 5x5 grid filled with 25 Option Buttons, now i want to make a loop that circles through them to see which one is selected and then compares that to a number in the database to see if something should be done. Is this possible? if so how?

Which Is Better, Pass, Or Not Pass By Reference?
I've asked this before but never got any response but its important and I
thought I'd pitch it again (hopefully a bit clearer)...

One can pass data from one function to another either by passing a copy, or
passing by reference.

My understanding of passing by reference (putting the & before a variable
during the function declaration) means that the original data is used.

My understanding of *not* passing by reference, (thus passing a copy)
literally means creating a copy of the data contained in my variables - thus doubling the memory usage for this data... even if its just a temporary while the function is being executed.

I *believed* (past tense) that one should only pass by reference if they
wanted the child function to change the data and pass the newer values back
to the parent function.

I'm now thinking that this is just a feature and not the only usage. I am
begining to think I should use "pass by reference" nearly all the time in
order to conserve memory (since I won't be creating copies of my variable
data in memory).

Would this be good practice? Am I right that passing by reference means that
my variable data is not duplicated thus using less memory than if I had
passed my variable data as a copy?

A For Loop That Loops 1.5 Times
Below is some code from a page of mine that is supposed to process form data. The data is made up of checkboxes that a user randomly selects when they want to delete a file from a list of files.

dbmysqlconnect_pgs();
for ($x = 0; $x <= count($checkbox); $x++)
{
$query2 = "SELECT name
FROM proposalinfo
WHERE propid='$propid'
";
$results2 = mysql_query($query2) or die("Error in query 2");
while($query_data = mysql_fetch_array($results2)) {
$name = $query_data["name"];
}
$query4 = "SELECT filename
FROM files
WHERE fileid='$checkbox[$x]'
AND propid='$propid'
";
$results4 = mysql_query($query4) or die("Error in query 4");
while($query_data = mysql_fetch_array($results4)) {
$filename = $query_data["filename"];
}

//THIS IS WHERE THE ARCHIVE OF THE OLD FILE IS PROCESSED
$query3 = "INSERT INTO archives
(date, userid, propid, filename, fileid)
VALUES (NOW(), '$userid', '$propid', '$filename', '$checkbox[$x]')
";
$results3 = mysql_query($query3) or die("Error in query 3");

$query4 = "SELECT date
FROM archives
WHERE fileid='$checkbox[$x]'
AND propid='$propid'
";
$results4 = mysql_query($query4) or die("Error in query 4");
while($query_data = mysql_fetch_array($results4)) {
$date = $query_data["date"];
}

//THIS IS WHERE THE RENAME OF THE FILE IS PROCESSED
$oldfilename=$filename;
$oldname="./" . $name . "/" . $oldfilename;
$newfilename=$oldfilename . $date;
$newname="/overflow/pgs_archives/" . $name . "_archive/" . $newfilename;

copy("$oldname", "$newname");
unlink("$oldname");

//THIS IS WHERE THE DELETE OF THE DB DATA IS PROCESSED
$query5 = "DELETE FROM files
WHERE fileid='$checkbox[$x]'
AND propid='$propid'
";
$results5 = mysql_query($query5) or die("Error in query 5");

$query6 = "DELETE FROM fileinfo
WHERE fileid='$checkbox[$x]'
";
$results6 = mysql_query($query6) or die("Error in query 6");
}

indentheader(&#3920;',ñ',&#3920;','header3','The selected files have been deleted from the system.');

The problem I am having is that this will only execute 1.5 times before failing. The failure is at query3. Basically if you selected two or more checkboxes you will only delete one of the entries. Query3 runs by itself just fine and works the first time. Anyone have any ideas?

For Loops Breaking At A Certain Multiple
Can someone help me out with writing a script that will make will loop 500 times, but at every 4th multiple, it will insert a peice of code?

I tried all day to get this, and so far, nothing has worked.

Loops In Template Class
I wrote a template class and now when i go to parse data that should loop, it will just parse the last entered field

[code}$map = $row['map'];
$win = $row['result'];

$output = "
<table border="0" width="100%" id="table3">

<tr>
<td bgcolor="#657685" width="26%" align="center"><b>
<font face="Verdana" size="1" color="#FFFFFF">
$row[team]</font></b></td>
<td bgcolor="#657685" width="38%" align="center">
<font color="#FFFFFF" size="1" face="Verdana">
$row[map]</font></td>
<td bgcolor="#657685" width="17%">
<p align="center">
<font size="1" face="Verdana" color="#FFFFFF">$row[roundwon] - $row[roundlost]</font></p></td>
<td bgcolor="#657685" width="11%">
<p align="center"><b>
<font color="$color" size="2" face="Verdana">$row[result]</font></b></p></td>
</tr>
</table></td>
</tr>
";

};
[/code] That is the code that fetches the information.

and here is the info for the template array


"MATCHES" =>"$output",

Also, the rest of the template class works fie but i don't know how im going to make it "loopable" as such.

Conditional Statements And Loops
Not long ago I was asked to give PHP lections to some private IT
school. I'm on second lection now, and will be teaching my :) students
conditional statements (if..else and switch) and loops (while and for).
That was my story, now the question.

Can you give me an advise on some geeky use of those statements to stir
up some enthusiasm in students.

For Loops.....code Breaks
I'm trying to read an excel worksheet (with more than 5000 rows and 30
columns) using PHP. I'm using the "excelreader" script I found over the
web - http://sourceforge.net/projects/phpexcelreader/.

Seems to me, the script reads the values in all cells correctly and
stores the total number of rows and columns existing in the worksheet
(For example, in the excel file I'm using - total rows: 5375 and cols:
37). The problem is when I try to print the values as a HTML table
(using two for loops), the script prints only first 236 rows and stops
execution. The following is the code snippet I use:

for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++)
{
echo "<TR>";
for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++)
{
echo "<TD>".$data->sheets[0]['cells'][$i][$j];
}
echo "<BR>";
}

I've also set the script execution time to 5-10 mins using
"set_time_limit" function, but the script still ends after printing 236
rows (takes less than a minute). I spot checked the cell values by
printing values from 300 to 500, 5200 to 5375 etc. The values seems to
okay and stored correctly in the arrays. From what I understood, the
for loops doesn't execute completely and I don't understand why?

I've also created a small test script to see if the loops work and the
following code breaks...I don't see a output.

<?php
set_time_limit(300);

for ($i = 1; $i <= 5000; $i++)
{
for($j = 1; $j <= 40; $j++)
{
$data[$i][$j] = "mycell - $i$j"; //. ($i * $j);
}
}
echo "PRINTING TABLE....<BR>";

echo "<table border=&#391;'>";
for ($i = 1; $i <= 1000; $i++)
{
echo "<TR><TD>[$i]";
for($j = 1; $j <= 20; $j++)
{
echo "<TD>". $data[$i][$j];
}
echo "<BR>";
}
echo "</table>";
?>

Loops, Php And Mysql Data
I am writing a profile creator script where a user gets
a URL invite in their mail in the form of;

http://domain.com/profile-create.ph...kd98jadf098asdf

Things are working well except for a small annoyance in which someone
might have a solution to.

In the event that someone accesses profile-create.php without an
access_code the script generates a warning. If there is an access_code
that matches the access code entered in the MySQL database then they
are directed to the profile creation page. My problem is;

If someone accesses profile-create.php with an access_code but it
doesn't match any entries in the database I would like to generate a
warning.

When I try to do this with an else statement it produces an error for
every access code listed in the database which isn't the correct one,
so I could end up with a successful profile creation page with a bunch
of errors.

I've played with break and pattern matching but no results. Here is
the script below.
[color=blue]
>---------------------------------------------------------------<[/color]

<?php

$access_code = $_GET['access_code'];

if ($access_code) {

echo db_connect();

$result = mysql_query('SELECT random_link FROM invites');

while ($row = mysql_fetch_array($result, MYSQL_NUM)) {

$random_link_db = $row[0];

if ($random_link_db == $access_code) {
echo profile_creator_page();
}

// Would like to insert an error warning here

}
}

else {
echo "Error!"
}

function profile_creator_page() {
echo "All's well!";
}

?>
[color=blue]
>---------------------------------------------------------------<[/color]

Struggling With Nested While Loops
I am trying to execute 2 queries and then output the results in 2 loops but
maybe I'm using the wrong approach.

$query_1 = "SELECT field_1 FROM table_1";
$result_1 = mysql_query($query_1) or die(mysql_error());

$query_2 = "SELECT field_2 FROM table_2";
$result_2 = mysql_query($query_2) or die(mysql_error());

while ($row_1 = mysql_fetch_row($result_1))
{
while ($row_2 = mysql_fetch_row($result_2))
{
print $row_1[0] . ' - ' . $row_2[0] . '<BR>'
}
}

While Loops With SUBSTRING_INDEX Problem
From the field 'division', I'm trying to take the number to the left and divide it by the number to the right of a "/" and then add 1 each time a condition is met. So that 10/1 = 11 and 5/2 = 3.5 whenever field_id=9 etc.

The code below (when without the while loops) works for a single row. But I'm new to PHP and cannot get it to loop correctly without outputing the right number against every left number in the division field, so 6 rows outputs 36 results instead of just 6 results. Code:

Loops / Page Numbers
What I'm trying to do, is look through a directory, grab all the files, store it into a variable, then divide the total number of files by 25 (the amount I want on each page) then echo it onto each page. I have everything set up thus far, however, I seem to be only able to get the 1st page to show the 1-25 and each page thereafter shows up blank. 

I think the problem is where I call if ($_GET["page"]==$single_page). I've tried changing that to WHILE but it ends up looping till I get a 30 second timeout. Any ideas or suggestions?

Break In Loops A Good Practice
I have come across a While loop that my best solution seems to be to use a Break. And as I have never used a break command from within a loop I was wondering if it is an acceptable practice in PHP.

Finite $_POST Loops Infinitely -
I have no idea why this is happening and I need someone to explain this
to me at the simplest level absolutely possible (pretend I'm a 10-year
old and explain it that way, please!)

This class method:

PHP Code:
/**
* Perform an array scan
*
* @access private
* @param array $array
* @see vname
*/
function &array_scan(&$array) {
if (is_array($array) && @sizeof($array) 0) {
print_r("sizeof(" . vname($array) . ") = " . sizeof($array) .
"<P>");
$index = 1;
foreach ($array as $key =$val) {
print_r("index = $index<P>"); $index++;
$this->setData($val);
print_r("key = $key and val = $val and this->data =
$this->data and array name = " . vname($array) . "<P>");
$this->scan($key, vname($array));
$array[$key] = $this->getData();
}

For Loops, Dates And Writing To A File
I'm using a for loop to create a sql statements for all date between a start
and end date supplied by a user. I then pull stuff out of a database and use
counter to add various things up for each date. I then want to write these
into a file but only have one line for each date.

The problem I've been having is that if there are 12 entries for a specific
date all of these go into the file but what I would like is to display the
totals for each date. The counters are adding up correctly but I'm not sure
how to get it to put one line into the file for each date. If I put the code
where it write to the file ouside the while loop it writes only the dates to
the file and not the conter values.

code:

for ($search = 0; $search <= $counter; $search++){
$sql = "SELECT * from rma WHERE (customer ='something' OR customer =
'something') AND (date_format(date,'%e-%b-%y') = '$dateArray[$search]')";

$sqlResult = mysql_query($sql, $conn) or die (mysql_error());
while ($reportArray = mysql_fetch_array($sqlResult)) {

$serial = $reportArray['serialNo'];

if (($serial > ?') && ($serial < ?')){
$batch2++;
}
$line = $dateArray[$search].",".$batch2."
";
fwrite($excelPointer, $line);
}
}

fclose($excelPointer);

Executing Nested Loops Properly
I am uploading a text file, parsing it via file(), exploding each line via explode() and then running an insert to database.

The problem is this: When I explode the rows in the file I need to make sure there are 8 elements in each array/row. If there aren't I need to exit the loop before inserting any records. I am not sure how to properly nest my loops, the code is below. (currently the code below exits the loop if 8 elements aren't found, but inserts records until that happens...) PHP Code:

Interrupting Long While Loops With Heading Rows
I have a lot of data that I am pulling from a MySQL DB and displaying it in a crude table. Is there anyway to start the while loop (pulling up say, 80 results), and direct it to print a row of headings every 20 results? So that way the users still know what they are looking at even when scrolled down to the bottom.

DBM Functions:: Undefined Functions Error
I have been trying to use the DBM Functions (dbmopen etc) in php but always get an undefined funtion error. Do I need to load something or change something in the .ini file to get it to work?

thanks
MIke

Arrays Within Arrays, How To Split
I have been stumped on this one and it is probably easier than I think it is, especially since my brain is fried.

This is what my array looks like:
array(7) { ["injuredPerson"]=> string(0) "" ["dates"]=> string(0) "" ["describe"]=> string(0) "" ["location"]=> string(0) "" ["type"]=> array(3) { [0]=> string(8) "abrasion" [1]=> string(10) "amputation" [2]=> string(12) "asphyxiation" } ["part"]=> string(0) "" ["times"]=> string(0) "" }

This is actually an array of information from a form check. I have the error handling check the form and depending on if there is an error or not, the array gets populated with "" or an actual value(s).

I am testing a checkbox area of the form (the name is type, so type can hold an array of values, thats why it currently contains abrasion, amputation, and asphyxiation).

I have had no problem going through the array until I get to the area with an array within the array. Let me give you some code so you can see how I am doing this:

Searching Arrays With Arrays
ive looked through alot of the array search functions and i dont think any of them support arrays as the "needle" to search for.

so say i had a numeric array, $array1 with say 5 elements, 0-4, each element is a single word, lowercase.

say i had another numeric array structured the same way called $array2 with say about 5 elements, 0-4. Is there a function which i could use or does anyone know of an easy way to search every element in $array1 and compair it through each of the elements of $array2? and if a duplicate is found in $array2 have that element be removed or unset? im sure this can be done probably easy with some kind of loop function, but thats my weak point right now in php and im working on it.

Why Pass The SID?
Although I understand that you can only pass your session ID from page to page using (1) cookies, or (2) sessions - im at a loss why you'd need to do this.

Why isn't it enough to just use 'session_start()' at the top of all your pages? On all the tests I've done, I can register variables and recall them on different pages by only calling session_start - but I saw in a recent post which said you should always pass the session ID too.

I realise there is a tutorial on this, and several (hundred) posts - most of which I've read, but can someone please explain this as basic as possible!

Pass A Value Or Something Like It
I want to know how to pass a certain value or anything like it when you try to click a "picture of a book" or its "name" to be pass on another web page that will show the "book picture", the "price of the book" and the "description" of it?

How To Pass And Use The & In A URL?
I want to pass a phrase in the URL that uses an ampersand:

"Black & White"

And I want to be able to 1) print it as is, and 2) insert it into a link. I think the problem lies in the spaces around the ampersand. I've tried various methods of replacing it with &amp; and &038; and replacing the spaces with %20 or + but it still causes trouble. Code:


Copyright © 2005-08 www.BigResource.com, All rights reserved