473,699 Members | 2,552 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to move arrays from html webpage to webpage?

Hello:

There are a couple techniques to move information from different html
web page to web page.
1. URL;
2. Cookie;
3. Form;
4. Session;

All the examples I found are move distinguished variables from page to
page, such as "?weight=20&nam e='apple'".
I need users choose from the first web page (the arrays will be
generated), then use it in second and third html web pages. How do I
transfer them (arrays) and which way is the best?

For example, if I have two arrays,

$fruit[] = array("apple", "pear", "orange");
and associative array
$myCats["Me"]="Merry";
$myCats["Pi"]="Pippin";
$myCats["He"]="Hergie";

How to do that?

Thanks in advance.

Z. D

Jan 15 '07 #1
9 1967
du*******@gmail .com wrote:
Hello:

There are a couple techniques to move information from different html
web page to web page.
1. URL;
2. Cookie;
3. Form;
4. Session;

All the examples I found are move distinguished variables from page to
page, such as "?weight=20&nam e='apple'".
I need users choose from the first web page (the arrays will be
generated), then use it in second and third html web pages. How do I
transfer them (arrays) and which way is the best?

For example, if I have two arrays,

$fruit[] = array("apple", "pear", "orange");
and associative array
$myCats["Me"]="Merry";
$myCats["Pi"]="Pippin";
$myCats["He"]="Hergie";

How to do that?

Thanks in advance.
You could use the "explode" and "compress" array functions in PHP.
Jan 15 '07 #2
<du*******@gmai l.comwrote in message
news:11******** **************@ 38g2000cwa.goog legroups.com...
Hello:

There are a couple techniques to move information from different html
web page to web page.
1. URL;
2. Cookie;
3. Form;
4. Session;

All the examples I found are move distinguished variables from page to
page, such as "?weight=20&nam e='apple'".
Arrays can be used as get parameters as well.
"?apple[0]=foo&apple[1]=bar&apple[jack]=baz" works just fine.
--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
sp**@outolempi. net | rot13(xv***@bhg byrzcv.arg)
Jan 15 '07 #3
du*******@gmail .com wrote:
Hello:

There are a couple techniques to move information from different html
web page to web page.
1. URL;
2. Cookie;
3. Form;
4. Session;

All the examples I found are move distinguished variables from page to
page, such as "?weight=20&nam e='apple'".
I need users choose from the first web page (the arrays will be
generated), then use it in second and third html web pages. How do I
transfer them (arrays) and which way is the best?

For example, if I have two arrays,

$fruit[] = array("apple", "pear", "orange");
and associative array
$myCats["Me"]="Merry";
$myCats["Pi"]="Pippin";
$myCats["He"]="Hergie";

How to do that?

Thanks in advance.

Z. D
A session is the easiest way.
Jan 15 '07 #4
Sanders Kaufman wrote:
You could use the "explode" and "compress" array functions in PHP.
serialize() and unserialize() would probably be better choices.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

Jan 15 '07 #5
du*******@gmail .com wrote:
There are a couple techniques to move information from different html
web page to web page.
1. URL;
2. Cookie;
3. Form;
4. Session;
All of them *could* be used to store and retrieve array information, but
sessions are by far the easiest.

The others are only capable of storing and retrieving strings (not
arrays), so you'd need to use/write functions to do array<=>string
conversion. (serialize() and unserialize() are the the built-in PHP
functions to convert between array and string, and should be used
unless you have an overwhelming reason not to.)

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

Jan 15 '07 #6
Toby Inkster wrote:
Sanders Kaufman wrote:
>You could use the "explode" and "compress" array functions in PHP.

serialize() and unserialize() would probably be better choices.

I thought those were the same thing.
What's the difference?
Jan 15 '07 #7
Sanders Kaufman wrote:
Toby Inkster wrote:
>Sanders Kaufman wrote:
>>You could use the "explode" and "compress" array functions in PHP.

serialize() and unserialize() would probably be better choices.

I thought those were the same thing.
What's the difference?
Firstly, there's no such function as "compress". I'd assumed you'd meant
"implode" which is the counterpart of "explode".

<?php

$orig = array('foo', 'bar', 'baz');
print "Original:\ n"; var_dump($orig) ;
$imploded = implode(':', $orig);
$serialized = serialize($orig );
print "Imploded is '$imploded'.\n" ;
print "Serialized is '$serialized'.\ n";
$exploded = explode(':', $imploded);
$unserialized = unserialize($se rialized);
print "Exploded:\ n"; var_dump($explo ded);
print "\nUnserialized :\n"; var_dump($unser ialized);

print "\n\n----------------------\n\n";

$orig = array('foo'=>12 , 'bar'=>24, 'baz'=>18);
print "Original:\ n"; var_dump($orig) ;
$imploded = implode(':', $orig);
$serialized = serialize($orig );
print "Imploded is '$imploded'.\n" ;
print "Serialized is '$serialized'.\ n";
$exploded = explode(':', $imploded);
$unserialized = unserialize($se rialized);
print "Exploded:\ n"; var_dump($explo ded);
print "\nUnserialized :\n"; var_dump($unser ialized);

?>

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

Jan 16 '07 #8
Toby Inkster wrote:
Sanders Kaufman wrote:
>>>You could use the "explode" and "compress" array functions in PHP.
serialize() and unserialize() would probably be better choices.
I thought those were the same thing.
What's the difference?

Firstly, there's no such function as "compress". I'd assumed you'd meant
"implode" which is the counterpart of "explode".

Yeah - that's what I meant :)
>
<?php

$orig = array('foo', 'bar', 'baz');
print "Original:\ n"; var_dump($orig) ;
$imploded = implode(':', $orig);
$serialized = serialize($orig );
print "Imploded is '$imploded'.\n" ;
print "Serialized is '$serialized'.\ n";
$exploded = explode(':', $imploded);
$unserialized = unserialize($se rialized);
print "Exploded:\ n"; var_dump($explo ded);
print "\nUnserialized :\n"; var_dump($unser ialized);

print "\n\n----------------------\n\n";

$orig = array('foo'=>12 , 'bar'=>24, 'baz'=>18);
print "Original:\ n"; var_dump($orig) ;
$imploded = implode(':', $orig);
$serialized = serialize($orig );
print "Imploded is '$imploded'.\n" ;
print "Serialized is '$serialized'.\ n";
$exploded = explode(':', $imploded);
$unserialized = unserialize($se rialized);
print "Exploded:\ n"; var_dump($explo ded);
print "\nUnserialized :\n"; var_dump($unser ialized);

?>
Jan 16 '07 #9
"Sanders Kaufman" <bu***@kaufman. netwrote in message
news:ot******** **********@news svr27.news.prod igy.net...
Toby Inkster wrote:
>Sanders Kaufman wrote:
>>You could use the "explode" and "compress" array functions in PHP.

serialize() and unserialize() would probably be better choices.


I thought those were the same thing.
What's the difference?

$original = array('foo'=>'b ar;zap');
print_r($origin al);
print_r(unseria lize(serialize( $original)));
print_r(explode (';', implode(';', $original)));

Differences when using explode/implode:
- keys are lost
- if a string value happens to have the split/glue character, it totally
messes up the array

serialize/unserialize preserves the array structure better. Implode and
explode aren't completely useless, on a special occasion they work just
fine, still serialize/unserialize is more stable solution.

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
sp**@outolempi. net | rot13(xv***@bhg byrzcv.arg)
Jan 16 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3455
by: Dariusz | last post by:
I want to use arrays in my website (flat file for a guestbook), but despite having read through countless online tutorials on the topic, I just can't get my code to work. I know there are guestbook scripts out there - but that doesn't help me learn how to programme arrays !!! The following is the code for the PHP (called externally), which does execute...
1
8038
by: teknowbabble | last post by:
I would like to know how to convert HTML code that users input into a TEXTAREA box on a HTML FORM into a separate WEBPAGE. I have something like the diagram below on my webpage. The user is prompted to input his/her HTML Code in the FORM TEXTAREA. By pushing the Make Webpage Button, a new window opens with the output of the HTML contents they inputted. This way people can see what their HTML looks like. HTML FORM TEXTAREA (Where user...
7
3725
by: Tim Conner | last post by:
Hi, I am an ex-delphi programmer, and I having a real hard time with the following simple code (example ): Which is the equivalent to the following code ? var chars : PChar; sBack, s : String;
2
2251
by: John | last post by:
Hello everyone, I'm currently writing a program to keep track of schedule changes at a school. The goal is to have someone using the program to declare changes, then the program writes a html file, which is uploaded to a webserver. Then students and teachers can view it online, but there are also a couple of computers with 19" monitors standing around the school to display the webpage (IE kiosk mode). The program has a form containing...
35
3029
by: Frederick Gotham | last post by:
(Before I begin, please don't suggest to me to use "std::vector" rather than actual arrays.) I understand that an object can have resources (e.g. dynamically allocated memory), and so we have to copy an object properly via copy- construction rather than using memcpy. However, is it okay to move an object manually (i.e. by using memcpy or memmove)?
4
15029
bats fur eels
by: bats fur eels | last post by:
Hi, I was hoping if anyone knew if it were possible using HTML or other basic scripts that enable you to lets say, scroll the webpage down a few margins upon load of page or script. So that it will automatically scroll down for you in case their is a certain spot of the website that you want them to see first. Or in the case of a profile, etc, you can automatically have it scroll down to a certain section in your profile instead of the user...
1
1941
by: rpjd | last post by:
I am completely new to this so please bear with me here. My project involves a webpage executing php scripts via an xmlhttprequest which queries a database and returns data to the webpage. This code below is working to a degree in IE7. As I have not yet parsed http.responseText, I am getting all the code in parts.php in the alert. My php script query creates two php arrays, one a single array and a two-dimensional array such as array. My...
2
3518
by: Andrew Neiderer | last post by:
This is simple HTML, Java but I am really confused. I include the code since it is so small - ---------------------------------------------------------------------------- -- test.html -- <html> <head> <title>
5
12850
sid0404
by: sid0404 | last post by:
Hi I am new to the visualstudio.net I am trying to develop an application which requires me to send data to a HTML webpage - http://patft.uspto.gov/netahtml/PTO/search-bool.html and the user sendsd the data to the webpage and receives the response to that particular values from the webpage. I am trying to use httpwebrequest for this purpose, but I am receiving errors, kindly let me know where I am going wrong. When I llok at the...
0
8687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9174
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9035
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8914
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8884
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7751
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5875
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2347
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.