[PHP] Re: Arrays
Philip W. wrote: Sorry if this question seems stupid - I've only had 3 days of PHP experience. When using the following string format, I get an error from PHP. $text['text'] = String Text ; Can someone help me? This seems ok and should not give any error. Mabye the error is of something else. What's the error you get? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Arrays not recognized in Simple XML Objects (using print_r)
Yashesh Bhatia wrote: hi! i'm trying to use the simple_xml functions to get an arrray of data from a sample xml file. here's my sample_data.xml ?xml version=1.0 encoding=ISO-8859-1? sample_data first_names first_nameamit/first_name first_nameamar/first_name /first_names /sample_data the php file ?php $sample_data = simplexml_load_file(sample_data.xml); print_r($sample_data); print_r($sample_data-first_names); print_r($sample_data-first_names-first_name); ? output of $ php test_xml_1.php SimpleXMLElement Object ( [first_names] = SimpleXMLElement Object ( [first_name] = Array ( [0] = amit [1] = amar ) ) ) SimpleXMLElement Object ( [first_name] = Array ( [0] = amit [1] = amar ) ) SimpleXMLElement Object ( [0] = amit ) The above output shows $sample_data-first_names-first_name as an ARRAY in the first 2 print_r 's however when a print_r is run on itself it shows it as a SimpleXMLElementObject. Question is why the last print_r gives different information compared to the other 2. I also tried running $key = array_rand($sample_data-first_names-first_name) and it gives a warning message Warning: array_rand(): First argument has to be an array in /home/yvb/work/practice/php/XML/foo.php on line 16 any clue how do i use the $sample_data-first_names-first_name as an array ? thx. yashesh. That's how print_r displays objects and nested objects - try a var_dump on the item and you'll see that simplexml does NOT return arrays but instead returns simplexml objects - if you want to use array_rand you can cast (http://www.php.net/manual/en/language.types.type-juggling.php#language.types.typecasting) the object to an array, or check out the user notes on simplexml http://us2.php.net/manual/en/ref.simplexml.php to find example functions to change a simplexml object to an array personally I prefer dom and use a domtoarray function - but YMMV - please read the simplexml documentation again, it returns objects (nested ones) NOT arrays -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Arrays Keys?
http://www.php.net/manual/en/function.setlocale.php That is the problem. I have tried that, but it needs to be installed. I'm not in a position to ask on this particular server. I have PHP Version 4.3.4 all the same. http://www.glquebec.org/English/test.php The code echoes Friday 22 December 1978Preferred locale for german on this system is '' ?php /* Set locale to Dutch */ setlocale(LC_ALL, 'nld_nld'); /* Output: vrijdag 22 december 1978 */ echo strftime(%A %d %B %Y, mktime(0, 0, 0, 12, 22, 1978)); /* try different possible locale names for german as of PHP 4.3.0 */ $loc_de = setlocale(LC_ALL, '[EMAIL PROTECTED]', 'de_DE', 'deu_deu'); echo Preferred locale for german on this system is '$loc_de'; ? Nadim Attari wrote: I'm doing the language thing. Is this what u r looking for ? http://www.php.net/manual/en/function.setlocale.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Arrays Keys?
I'm doing the language thing. Is this what u r looking for ? http://www.php.net/manual/en/function.setlocale.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: arrays and php
echo td width=\15\ bgcolor=\#9FD9FF\ input type=\checkbox\ name=\chkR[$i]\ value=\$chkSessionF[$i]\/td); might solve the problem pete hi I have a table with rows and each row contains a checkbox ( array) and a record. TD of the checkbox: echo(td width=15 bgcolor=#9FD9FFinput type=checkbox name=chkR[] value=. $chkSessionF[$i] ./td); as you can see the array of checkboxes is called chkR. When the user clicks a submit button it calls the same page and the value of the array is received using: $chkR=$_POST['chkR']; however this variable is doing something weird because if I immediately do: echo(chk: is array: . is_array ($chk)); it doesnt display anything, so I presume it isnt an array, supporting this is also the fact that I try to use the $chkR in: $indReqF = array_diff ($indReq, $chkR) and everytime i run this statement php tells me that the 2nd argument isnt an array. What is the reason for $chkR not being an array? I have used the same code on a different page but instead of it posting to the same page (like in this example) it posts to another page and works fine !?!?!?!? can anyone help. this is very strange. thanx in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: arrays
this should work: for ($i=0; $i5; $i++) { $mypics[$i] = $picture; } Edward Peloke wrote: Ok, very basic question, how do I am going through a loop 5 times, each time, I want to store a value into an array, do I simply set the value of $picture=array($mypics); and each time it loops it will take the current value of $picture and then I can get out each value by $mypics[0], $mypics[1], etc? Thanks, Eddie -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: arrays, variables, and register_globals--solved--thank you
Thank you very much, David--you understood the problem exactly and your solution worked perfectly! I'd like to add a comment about mysql_data_seek to the php manual entry on mysql_fetch_row, because I would think that this might be a common problem... Matt - Original Message - From: David Robley [EMAIL PROTECTED] To: GOLD, MATTHEW [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, July 25, 2002 5:37 AM Subject: RE: [PHP-DB] Re: arrays, variables, and register_globals So what you want to do is print a field from the first row extracted from the table, then loop through all the rows and print several fields? I think you want mysql_data_seek. Whenever you do a mysql_fetch_row, php grabs the current row from the result set, and shifts a pointer to the next record in the result set. In this case it seems you need to print from the first record, then reset the pointer to the first record and print from all records found. So: $row = mysql_fetch_row ($result)) print ($row[4]); mysql_data_seek($result, 0); // Add this while ($row = mysql_fetch_row ($result)) Unless I misunderstand what you are trying to do Cheers -- David Robley Temporary Kiwi! Quod subigo farinam I've been to a film festival in the South of France, said Tom cannily. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Arrays and Regs
Firstly, many thanks to Richard and Dan... A quick test script in PHP would have been faster than asking... :-) It was just one of those questions that I had burning in my mind at the time, and since I don't have access to PHP at work (As if the Government would allow that!), I had to ask :o) And to Dan: I would love to change the line margins of my email client, but unfortunately Novell Groupwise sucks, and the government will not, without exception, allow customization of any software, whatsoever. So I'm stuck with it. Thanks again guys! Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Arrays and Regs
Just a performance question, if anyone knows for sure. Within a large array, would using numerical indices be quicker than associative? I'm talking about a *noticeable* difference in performance, here. Almost for sure, nope. Run a test for yourself. Also, on Regular Expression replacements: $text = eregi_replace(([abc]+), span style=\color: red\\\1/span, $text); Would this replace any occurences of the pattern with the same pattern match in red text? I'm not sure exactly how the \\1, \\2, etc. works. So, does: Yes, for those browsers that understand the span tag. A quick test script in PHP would have been faster than asking... :-) $text = eregi_replace((a)(b)(c), \\1, $text); Does this output only the 'a'? I find this confusing for some reason, hehe. Any help would be great! Yes. If you had \\2 and \\3 somewhere, they'd be 'b' and 'c' respectively. Again a quick test script in PHP would have been faster... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Arrays
I have figured out how to do it thanks for you guys help.. Just one thing... ? $contact = array( 'moreinfo.php' = 'More Info' , 'contact.php' = 'Contact Us' , 'apage.php' = 'A Page' ); foreach ($contact as $link = $name) { echo lia href='. $link .'. $name ./a/libr; } ? What I need to do now is in the echo string is make use something like: $echo = lia href='. $link .'. $name ./a/libr; I have tryed doing it this way but it will only desplay one array when I call $echo down the page. What can I do to desplay all of them? Dan [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I'm trying to get my head around arrays and how to munipulate them. what I need to do is add html around the arrays eg. lia href='.$link(0).'.$name./a/li; I have my head around that but I the number of lines the I need to create is going to change so I need the script to repeat untill all the arrays are used. -- - Daniel Broome, siliconBLUE Ltd, Web Author, http://siliconblue.com Mob: 64-21-178-5120 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Arrays
use .= instead of = $echo .= lia href='. $link .'. $name ./a/libr; (remember to initialise $echo = somewhere first just in case is contains something from elsewhere) -Original Message- From: Dan [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 11, 2002 11:36 AM To: [EMAIL PROTECTED] Subject: [PHP] Re: Arrays I have figured out how to do it thanks for you guys help.. Just one thing... ? $contact = array( 'moreinfo.php' = 'More Info' , 'contact.php' = 'Contact Us' , 'apage.php' = 'A Page' ); foreach ($contact as $link = $name) { echo lia href='. $link .'. $name ./a/libr; } ? What I need to do now is in the echo string is make use something like: $echo = lia href='. $link .'. $name ./a/libr; I have tryed doing it this way but it will only desplay one array when I call $echo down the page. What can I do to desplay all of them? Dan [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I'm trying to get my head around arrays and how to munipulate them. what I need to do is add html around the arrays eg. lia href='.$link(0).'.$name./a/li; I have my head around that but I the number of lines the I need to create is going to change so I need the script to repeat untill all the arrays are used. -- - Daniel Broome, siliconBLUE Ltd, Web Author, http://siliconblue.com Mob: 64-21-178-5120 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Arrays
$echo .= lia href='. $link .'. $name ./a/libr; Notice the . in .= Equivalent of saying $echo = $echo . lia href='. $link .'. $name ./a/libr; ---John Holmes... -Original Message- From: Dan [mailto:[EMAIL PROTECTED]] Sent: Monday, June 10, 2002 9:36 PM To: [EMAIL PROTECTED] Subject: [PHP] Re: Arrays I have figured out how to do it thanks for you guys help.. Just one thing... ? $contact = array( 'moreinfo.php' = 'More Info' , 'contact.php' = 'Contact Us' , 'apage.php' = 'A Page' ); foreach ($contact as $link = $name) { echo lia href='. $link .'. $name ./a/libr; } ? What I need to do now is in the echo string is make use something like: $echo = lia href='. $link .'. $name ./a/libr; I have tryed doing it this way but it will only desplay one array when I call $echo down the page. What can I do to desplay all of them? Dan [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I'm trying to get my head around arrays and how to munipulate them. what I need to do is add html around the arrays eg. lia href='.$link(0).'.$name./a/li; I have my head around that but I the number of lines the I need to create is going to change so I need the script to repeat untill all the arrays are used. -- - Daniel Broome, siliconBLUE Ltd, Web Author, http://siliconblue.com Mob: 64-21-178-5120 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: arrays
Can arrays be passed to functions just like a simple variable? yes, no difference. You can pass every variable to a function, you can pass constants or your values directly. You have to use a variable if a function requires passing by reference or if you want to pass by refernce, because only variables can take the value back. Can arrays be passed as values in hidden form fields just like a simple variable? yes, but differently. either you serialize the array, send it urlencoded to the page and unserialze it there: //page1.php: ?php $array = array(1,2,3,4,5); $array = urlencode(serialize($array)); ? a href=page2.php?array=?php echo $array; ?Page2/a //or input field: input type=hidden name=array value=?php echo $array; ? //page2.php ?php $array = unserialize($array); print_r($array); ? or you can appen urls like this, no serialization or sth needed then both pages: numerical indexed arrays: a href=page2.php?array[]=1array[]=2array[]=3array[]=4array[]=5Page2/a or a href=page2.php?array[0]=1array[1]=2array[2]=3array[3]=4array[4]=5Page 2/a string indexed arrays: a href=page2.php?array[test1]=1array[test2]=2array[test3]=3array[test4]=4 array[test5]=5Page2/a or with forms: numerical indexed arrays: input type=hidden name=array[] value=1 input type=hidden name=array[] value=2 input type=hidden name=array[] value=3 input type=hidden name=array[] value=4 input type=hidden name=array[] value=5 or input type=hidden name=array[0] value=1 input type=hidden name=array[2] value=2 input type=hidden name=array[3] value=3 input type=hidden name=array[4] value=4 input type=hidden name=array[5] value=5 string indexed arrays: input type=hidden name=array[test1] value=1 input type=hidden name=array[test2] value=2 input type=hidden name=array[test3] value=3 input type=hidden name=array[test4] value=4 input type=hidden name=array[test5] value=5 Michael Michael Hall [EMAIL PROTECTED] schrieb im Newsbeitrag [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... A couple of simple ones here ... the usual references don't appear to give a straightforward answer on these: Can arrays be passed to functions just like a simple variable? Can arrays be passed as values in hidden form fields just like a simple variable? I've been playing around with these and getting inconsistent results. I've been trying things like serialize and urlencode, but still haven't worked out a straightforward 'rule' or policy. Can someone throw some light on this? TIA Michael -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Arrays/OOP
Joshua E Minnie wrote: while(!feof($fp)) { $temp = fgetcsv($fp, 1024, :); $event_list[$i] = $event_object-init($temp[0],$temp[1],$temp[2],$temp[3],$temp[4],$temp[5],$temp[6],$temp[7],$temp[8]); $i++; } Without seeing more of the code, I can't say for certain, but I suspect that instead of $event_object-init you need to call $this-init Does that do the trick? Wait - I looked above $event_object = new event() What is the class definition for event? Could you send more code? Michael Kimsal http://wwwphphelpdeskcom 734-480-9961 -- PHP General Mailing List (http://wwwphpnet/) To unsubscribe, visit: http://wwwphpnet/unsubphp
Re: [PHP] Re: Arrays/OOP
Michael Kimsal wrote: Joshua E Minnie wrote: while(!feof($fp)) { $temp = fgetcsv($fp, 1024, :); $event_list[$i] = $event_object-init($temp[0],$temp[1],$temp[2],$temp[3],$temp[4],$temp[5],$t emp[6],$temp[7],$temp[8]); $i++; } Without seeing more of the code, I can't say for certain, but I suspect that instead of $event_object-init you need to call $this-init. Does that do the trick? Wait - I looked above. $event_object = new event(). What is the class definition for event? Could you send more code? Michael Kimsal http://www.phphelpdesk.com 734-480-9961 Attached you will find the class definition. Thanks in advance.. Joshua E Minnie CIO [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Arrays/OOP
Joshua E Minnie wrote: Michael Kimsal wrote: Attached you will find the class definition. Thanks in advance.. Joshua E Minnie CIO [EMAIL PROTECTED] What version of PHP are you using? I took the file and it seemed to work OK in PHP 4.0.5. Michael Kimsal http://www.phphelpdesk.com 734-480-9961 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Arrays/OOP
Michael Kimsal wrote: What version of PHP are you using? I took the file and it seemed to work OK in PHP 4.0.5. Michael Kimsal http://www.phphelpdesk.com 734-480-9961 I am currently using PHP 4.1.2. Maybe it's in the file that I am using for testing, I have attached the code. Joshua E Minnie CIO [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Arrays/OOP
Michael Kimsal wrote: Still works - at least, I'm not getting the error you posted. Is there something else we may be missing? What line(s) are causing a problem? On line 21 of the corrected test file that I attached previously. Joshua E Minnie [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Arrays as pointers?
In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... A friend of mine showed me this code recently. function firstLogin_string() { mt_srand(make_seed()); $pool = AaBbCcDdEeFfGgHhIiJjKkLlM; $length = 26; for($i=0; $i $length; $i++) { $key .= $pool[mt_rand(0,strlen($pool)-1)]; } return $key; } look at the for loop. $pool is not an array but is being treated as such and the key happens to be the position in $pool and it'll take that letter and save it to $key. I've never seen this done before. What is this method called and what other neat tricks can you do in respect to this? This is documented behaviour - from the manual: String access by character Characters within strings may be accessed by specifying the zero-based offset of the desired character after the string in curly braces. Note: For backwards compatibility, you can still use the array-braces. However, this syntax is deprecated as of PHP 4. Use limitd only by your imagination :-) -- David Robley Temporary Kiwi! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: arrays
The best thing for converting XML to HTML is XSLT (that's what it was made for). PHP can do the convertion using the XSLT functions (which require Sablotron): http://www.php.net/manual/ref.xslt.php Peter Php Dood [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I'm trying to figure out how to parse an xml document, and convert it into html... i know how to parse in simple xml stuff for example easyeasy/easy is pretty easy to parse in, and i know how to code that, but when you start adding flags that i'm going to need variables for, example easy does=1 it=2easy/easy is not so easy. *** paste sample xml *** report gmt_date=1206082001 unix_date=992001907.00 location city=11531 forecast day_sequence=1 day_of_week=6 daylight=D date=060801 high_temp=24.78 low_temp=14.51 sky_desc=3 precip_desc=* temp_desc=8 air_desc=* uv_index=7 wind_speed=18.51 wind_dir=270 humidity=48 dew_point=12.01 comfort=25.28 rainfall=* snowfall=* precip_prob=0 icon=2 / forecast day_sequence=2 day_of_week=7 daylight=D date=060901 high_temp=20.34 low_temp=13.68 sky_desc=1 precip_desc=* temp_desc=7 air_desc=20 uv_index=7 wind_speed=18.51 wind_dir=270 humidity=57 dew_point=9.23 comfort=19.23 rainfall=* snowfall=* precip_prob=2 icon=1 / forecast day_sequence=3 day_of_week=1 daylight=D date=061001 high_temp=20.35 low_temp=12.01 sky_desc=3 precip_desc=* temp_desc=7 air_desc=* uv_index=7 wind_speed=* wind_dir=* humidity=56 dew_point=9.80 comfort=* rainfall=* snowfall=* precip_prob=1 icon=2 / forecast day_sequence=4 day_of_week=2 daylight=D date=061101 high_temp=20.34 low_temp=12.02 sky_desc=3 precip_desc=* temp_desc=7 air_desc=* uv_index=7 wind_speed=* wind_dir=* humidity=57 dew_point=10.34 comfort=* rainfall=* snowfall=* precip_prob=1 icon=2 / forecast day_sequence=5 day_of_week=3 daylight=D date=061201 high_temp=22.01 low_temp=13.12 sky_desc=3 precip_desc=* temp_desc=7 air_desc=* uv_index=7 wind_speed=* wind_dir=* humidity=55 dew_point=11.45 comfort=* rainfall=* snowfall=* precip_prob=1 icon=2 / forecast day_sequence=6 day_of_week=4 daylight=D date=061301 high_temp=23.12 low_temp=13.12 sky_desc=7 precip_desc=* temp_desc=7 air_desc=* uv_index=7 wind_speed=* wind_dir=* humidity=46 dew_point=9.79 comfort=* rainfall=* snowfall=* precip_prob=2 icon=2 / forecast day_sequence=7 day_of_week=5 daylight=D date=061401 high_temp=23.12 low_temp=13.68 sky_desc=7 precip_desc=* temp_desc=7 air_desc=* uv_index=7 wind_speed=* wind_dir=* humidity=49 dew_point=10.34 comfort=* rainfall=* snowfall=* precip_prob=3 icon=2 / /location -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: arrays
Well, to do this you'll just have to write a loop that takes in every identifier=value pair and converts them into an array of values attached to the tag name. You'll have to parse the input character by character. The following pseudo code might help to explain a bit: // input[x] refers to the character at position x in the string input input = report gmt_date=1206082001 unix_date=992001907.00/report; for (x = 0, x is each character in input) { if (input[x] equals ) { $tagname = getName(x); // returns the tag name, will stop at first white space for (y = x, y is each character in input beginning at pos x) { if (input[y] equals ) { continue; //skips white space } else if (input[y] equals =) { $value = getValue(y); //returns value beginning and ending with quotes addToArray($tagname, $paramname, $value); //adds the parsed values to an array } else { $paramname = getParam(y); // returns param name up to whitespace or '=' sign. } } } Php Dood [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I'm trying to figure out how to parse an xml document, and convert it into html... i know how to parse in simple xml stuff for example easyeasy/easy is pretty easy to parse in, and i know how to code that, but when you start adding flags that i'm going to need variables for, example easy does=1 it=2easy/easy is not so easy. *** paste sample xml *** report gmt_date=1206082001 unix_date=992001907.00 location city=11531 forecast day_sequence=1 day_of_week=6 daylight=D date=060801 high_temp=24.78 low_temp=14.51 sky_desc=3 precip_desc=* temp_desc=8 air_desc=* uv_index=7 wind_speed=18.51 wind_dir=270 humidity=48 dew_point=12.01 comfort=25.28 rainfall=* snowfall=* precip_prob=0 icon=2 / forecast day_sequence=2 day_of_week=7 daylight=D date=060901 high_temp=20.34 low_temp=13.68 sky_desc=1 precip_desc=* temp_desc=7 air_desc=20 uv_index=7 wind_speed=18.51 wind_dir=270 humidity=57 dew_point=9.23 comfort=19.23 rainfall=* snowfall=* precip_prob=2 icon=1 / forecast day_sequence=3 day_of_week=1 daylight=D date=061001 high_temp=20.35 low_temp=12.01 sky_desc=3 precip_desc=* temp_desc=7 air_desc=* uv_index=7 wind_speed=* wind_dir=* humidity=56 dew_point=9.80 comfort=* rainfall=* snowfall=* precip_prob=1 icon=2 / forecast day_sequence=4 day_of_week=2 daylight=D date=061101 high_temp=20.34 low_temp=12.02 sky_desc=3 precip_desc=* temp_desc=7 air_desc=* uv_index=7 wind_speed=* wind_dir=* humidity=57 dew_point=10.34 comfort=* rainfall=* snowfall=* precip_prob=1 icon=2 / forecast day_sequence=5 day_of_week=3 daylight=D date=061201 high_temp=22.01 low_temp=13.12 sky_desc=3 precip_desc=* temp_desc=7 air_desc=* uv_index=7 wind_speed=* wind_dir=* humidity=55 dew_point=11.45 comfort=* rainfall=* snowfall=* precip_prob=1 icon=2 / forecast day_sequence=6 day_of_week=4 daylight=D date=061301 high_temp=23.12 low_temp=13.12 sky_desc=7 precip_desc=* temp_desc=7 air_desc=* uv_index=7 wind_speed=* wind_dir=* humidity=46 dew_point=9.79 comfort=* rainfall=* snowfall=* precip_prob=2 icon=2 / forecast day_sequence=7 day_of_week=5 daylight=D date=061401 high_temp=23.12 low_temp=13.68 sky_desc=7 precip_desc=* temp_desc=7 air_desc=* uv_index=7 wind_speed=* wind_dir=* humidity=49 dew_point=10.34 comfort=* rainfall=* snowfall=* precip_prob=3 icon=2 / /location -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: arrays
Oh, and don't forget to check for the trailing tags i.e. the /report etc. Jeremy Reed [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Well, to do this you'll just have to write a loop that takes in every identifier=value pair and converts them into an array of values attached to the tag name. You'll have to parse the input character by character. The following pseudo code might help to explain a bit: // input[x] refers to the character at position x in the string input input = report gmt_date=1206082001 unix_date=992001907.00/report; for (x = 0, x is each character in input) { if (input[x] equals ) { $tagname = getName(x); // returns the tag name, will stop at first white space for (y = x, y is each character in input beginning at pos x) { if (input[y] equals ) { continue; //skips white space } else if (input[y] equals =) { $value = getValue(y); //returns value beginning and ending with quotes addToArray($tagname, $paramname, $value); //adds the parsed values to an array } else { $paramname = getParam(y); // returns param name up to whitespace or '=' sign. } } } Php Dood [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I'm trying to figure out how to parse an xml document, and convert it into html... i know how to parse in simple xml stuff for example easyeasy/easy is pretty easy to parse in, and i know how to code that, but when you start adding flags that i'm going to need variables for, example easy does=1 it=2easy/easy is not so easy. *** paste sample xml *** report gmt_date=1206082001 unix_date=992001907.00 location city=11531 forecast day_sequence=1 day_of_week=6 daylight=D date=060801 high_temp=24.78 low_temp=14.51 sky_desc=3 precip_desc=* temp_desc=8 air_desc=* uv_index=7 wind_speed=18.51 wind_dir=270 humidity=48 dew_point=12.01 comfort=25.28 rainfall=* snowfall=* precip_prob=0 icon=2 / forecast day_sequence=2 day_of_week=7 daylight=D date=060901 high_temp=20.34 low_temp=13.68 sky_desc=1 precip_desc=* temp_desc=7 air_desc=20 uv_index=7 wind_speed=18.51 wind_dir=270 humidity=57 dew_point=9.23 comfort=19.23 rainfall=* snowfall=* precip_prob=2 icon=1 / forecast day_sequence=3 day_of_week=1 daylight=D date=061001 high_temp=20.35 low_temp=12.01 sky_desc=3 precip_desc=* temp_desc=7 air_desc=* uv_index=7 wind_speed=* wind_dir=* humidity=56 dew_point=9.80 comfort=* rainfall=* snowfall=* precip_prob=1 icon=2 / forecast day_sequence=4 day_of_week=2 daylight=D date=061101 high_temp=20.34 low_temp=12.02 sky_desc=3 precip_desc=* temp_desc=7 air_desc=* uv_index=7 wind_speed=* wind_dir=* humidity=57 dew_point=10.34 comfort=* rainfall=* snowfall=* precip_prob=1 icon=2 / forecast day_sequence=5 day_of_week=3 daylight=D date=061201 high_temp=22.01 low_temp=13.12 sky_desc=3 precip_desc=* temp_desc=7 air_desc=* uv_index=7 wind_speed=* wind_dir=* humidity=55 dew_point=11.45 comfort=* rainfall=* snowfall=* precip_prob=1 icon=2 / forecast day_sequence=6 day_of_week=4 daylight=D date=061301 high_temp=23.12 low_temp=13.12 sky_desc=7 precip_desc=* temp_desc=7 air_desc=* uv_index=7 wind_speed=* wind_dir=* humidity=46 dew_point=9.79 comfort=* rainfall=* snowfall=* precip_prob=2 icon=2 / forecast day_sequence=7 day_of_week=5 daylight=D date=061401 high_temp=23.12 low_temp=13.68 sky_desc=7 precip_desc=* temp_desc=7 air_desc=* uv_index=7 wind_speed=* wind_dir=* humidity=49 dew_point=10.34 comfort=* rainfall=* snowfall=* precip_prob=3 icon=2 / /location -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: Arrays in form
Use JavaScript. Read PHP Manul if you need to pass array form vars. There is a section for that. Srinivasan ranganathan wrote: Hi all How can i implement a hotmail-inbox like checkbox functionality? thanks in adv Regards Srinivasan Ranganathan -- Yasuo Ohgaki -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Re: Arrays in form
You don't need to use javascript unless you're lookin for select all functionality. I think what you are looking for might just be to have many checkboxes that can be selected at a time? You can look in the manual, but the trick is just to name your form fields with a [] at the end. So, it would be like input type=checkbox name=messageid[] ... That will ensure that PHP takes all checked messageid boxes and sticks them in an array for ya! Hope that helps! Brian Tanner Project Manager Zaam Internet Solutions Toll Free: 1-866-225-2675 [EMAIL PROTECTED] http://www.zaam.com -Original Message- From: Yasuo Ohgaki [mailto:[EMAIL PROTECTED]] Sent: October 21, 2001 10:50 PM To: Subject: [PHP] Re: Arrays in form Use JavaScript. Read PHP Manul if you need to pass array form vars. There is a section for that. Srinivasan ranganathan wrote: Hi all How can i implement a hotmail-inbox like checkbox functionality? thanks in adv Regards Srinivasan Ranganathan -- Yasuo Ohgaki -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]