Jump to content

boff2000

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Everything posted by boff2000

  1. Do you need to use getElementsByTagName in order to get to node data? I would rather parse XML with indexes. I've looked at DOMNodeList-item(), but it only seems to work after getElementsByTagName is used.. What is an alternate for the code below using indexes? [code]<?php $doc = new DOMDocument(); $doc -> load("file.xml"); $items = $doc->getElementsByTagName("ITEM"); $name = $doc->getElementsByTagName("NAME"); $age = $doc->getElementsByTagName("AGE"); echo $name->item(0)->nodeValue . '<br>' .  $age->item(0)->nodeValue; //Anders  2 ?>[/code] XML: <?xml version="1.0"?> <CONTENT> <ITEM> <NAME>Anders</NAME> <NICKN>Andy</NICKN> <AGE>2</AGE> </ITEM> </CONTENT>
  2. I know that to get the code below to work, i could put $var in both func() brackets - but - is there any way around this? If i had say 10 variables, i would have to put them all in the brackets - and to me thats not very modular if you are going to have quite a few functions in a page  :-[ [code]$var = "text"; function func(){ echo $var; } func(); [/code]
  3. Thanks for the replies! Crayon Violent - yes i understand whats happening - i echoed the the results twice to test if each time returned the same result. Anyway - for the example i provided, the solutions you guys provided worked for it.. however, i thought i may have been able to apply that logic to what im doing. i actually want to send a multi-dimensional array. The reason being, I want to send it somewhere so that other functions can then edit elements of the array - then ultimately have it all write to XML (but ive got that bit sorted :P ) im doing something wrong about half way through this code.. i bet [code]<?php //Create the array only when $cmd does not exist if(!$cmd){ $arr = array(); $arr[0][0] = "a"; $arr[0][1] = "b"; $arr[1][0] = "y"; $arr[1][1] = "z"; } echo "<form action='page.php' method='post'>"; //put the multi-dimensional array into input elements foreach ($arr as $v1) {   foreach ($v1 as $v2) { echo "<input type='hidden' name='arr[]' value='$v2' />"; } } echo "<input type='submit' name='cmd' value='go' /></form>"; //If $cmd exists, return the array switch($_REQUEST['cmd']){     case "go":  foreach ($arr as $v1) {   foreach ($v1 as $v2) {   echo $v2; } }     break; } ?>[/code]
  4. hm, ok i tried that to no avail. i think id better paste an example: [code]<?php if(!$cmd){ $array_name = array( "Some text" ); echo $array_name[0]; } echo "<form action='page.php' method='post'> <input type='hidden' name='array_name[]' /> <input type='submit' name='cmd' value='go' /> </form>"; switch($_REQUEST['cmd']){     case "go":  echo $array_name[0];     break; } ?> [/code] ???
  5. How can I send an array from a form? I try creating a hidden input element with name='array_name' and value='$array_name' , but it doesnt seem to happen for me. I know I'm doing something wrong  :'( Im quite sure this is totally a newbie question  :-[
  6. I recently installed php4 on my local apache server and it seems to be working. However, I'm creating a php CMS for xml content, so ive learnt i need to enable the DOMXML extension. I enabled it by uncommenting the line in the php.ini file. I ran a test, and it says that domxml IS enabled - however, im still getting domxml_open_file() errors. this is a test on my hosting server (where it all actually works - the problem is on my local server) [a href=\"http://www.busnumber56.com/test.php\" target=\"_blank\"]http://www.busnumber56.com/test.php[/a] this is a test on my local server **might be down, depending if im home or not :P ** [a href=\"http://palangi.mine.nu:57/test.php\" target=\"_blank\"]http://palangi.mine.nu:57/test.php[/a] I have a feeling it has something to do with this configuration stuff.. eg: './configure' '--prefix=/usr/local' '--enable-discard-path' '--with-gettext' '--enable-exif' '--enable-bcmath' '--enable-calendar' ' I have NO idea how to get all that happening. googled for houuurs!
×
×
  • Create New...

Important Information

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