Jump to content

salathe

Staff Alumni
  • Posts

    1,832
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by salathe

  1. You missed out possibly the most valuable piece of information, an example of the XML file (or the actual file itself, that's good too).
  2. Yes! Just to confirm, only lady badgers.
  3. Hi, welcome to PHPFreaks. Please make sure to thoroughly search the site, forums and entire intarwebs before posting up a thread anyway, because we need the extra post counts! Kindly, PHPFreaks Badger
  4. Where? Is he behind me? *looks around* (P.S. You're welcome. )
  5. I'm not sure which "security update" you're referring to (a link to the information would be nice) but if your script needs those INI options to be turned on to work, then turn them on.
  6. You shouldn't be appending multiple elements to the document. In short, your line which contains $doc->appendChild($occ) should be changed to $root->appendChild($occ).
  7. You're not seeing the true output from print_r() there. Since XML tags are being printed, your browser is thinking they're HTML tags and not displaying them. Either output your page as plain text (by sending the appropriate Content-Type header, or specifying the default_mimetype PHP.ini setting in your script) or "view source" in your browser.
  8. Don't be too worried about the DOMDocument and DOMXPath objects appearing "empty" with print_r() and var_dump()... that's just how they roll. To know whether the XML was loaded, the load() method would return FALSE on failure and usually a whole heap of E_WARNINGs would be emitted. To check and see what was loaded, call the document's saveXML() method. To see if there was an error with the XPath query, the query() method would return FALSE and again E_WARNING messages will be issued (remember to turn up your error reporting!). If the XPath query was OK and you want to check how many (if any) nodes were matched, then examine the length property on the DOMNodeList returned from query().
  9. Those relative formats [1] only accept integer numbers, if you want to use a fractional part of a unit then you must instead use a whole number of smaller units. As requinix said, use hours and minutes. [1] http://php.net/datetime.formats.relative
  10. RAND() is a function and must be used as such, parentheses are needed.
  11. [studied at|Went to] is a character class asking to match any one character from the list of S, t, u, d, i, and so on. So, the letter "t" from "Works at" successfully matches at that point! You want to use a group (parentheses) rather than a character class (square brackets).
  12. No, not at all. The code should be simple enough to see that it doesn't! If you just want the directions on a map, read the JavaScript API documentation. Which makes your request not a PHP question, but instead a JavaScript one. There likely are PHP functions/classes available to put a map onto a page, but they will just be writing the appropriate JavaScript rather than doing anything special or specific to PHP.
  13. For the string that doesn't work, there is no "Med Admin Route" part for the first intervention (it's easy enough to make parts optional in regex, do a search) and likely no carriage return (\r) character at the end of the last one. That would explain only matching one of those three.
  14. It's a fairly simply matter to use the Directions API with PHP. Here's an example which takes you down the Royal Mile in Edinburgh, Scotland. <?php $endpoint = 'http://maps.googleapis.com/maps/api/directions/json?'; $params = array( 'origin' => 'St Giles Cathedral, Edinburgh', 'destination' => 'Holyrood Palace, Edinburgh', 'mode' => 'walking', 'sensor' => 'false', ); // Fetch and decode JSON string into a PHP object $json = file_get_contents($endpoint.http_build_query($params)); $data = json_decode($json); // If we got directions, output all of the HTML instructions if ($data->status === 'OK') { $route = $data->routes[0]; foreach ($route->legs as $leg) { foreach ($leg->steps as $step) { echo $step->html_instructions . "<br>\n"; } } }
  15. Hi Helen, welcome to PHPFreaks. Have you tried any of PHP's XML classes/functions yourself? The task is pretty simple but without knowing what, if anything, you've tried so far it's difficult to know where to pitch an answer. Boil the problem down to something basic that you can figure out, without the distraction of the rest of your script. <?php $xml = '<?xml version="1.0" encoding="utf-8"?> <elements> <facebookilike identifier="78a0daa1-8b7e-4793-9f19-65991d485a3c"> <value><![CDATA[1]]></value> </facebookilike> <text identifier="c5bba97d-1158-4359-9089-9f35b243a60f"> <value/> </text> <text identifier="70e50e8d-2a2d-4ca4-9f4e-0f691aaf7a96"> <value><![CDATA[Olivia Palermo]]></value> </text> <text identifier="b4ba2eaf-ae3c-4e31-81fa-979cfd9fe811"> <value><![CDATA[£590]]></value> </text> <link identifier="d6539bee-d12b-4a66-b8a1-fd0a7c42cda7"> <value><![CDATA[http://www.theitguide.com]]></value> <text/> <target/> <custom_title/> <rel/> </link> <textarea identifier="beab45eb-b32a-4766-822d-b3fb72b5b1d4"> <value><![CDATA[<p>Red satin pumps with ruffle fan back and a heel that measures approximately 150mm/ 6 inches with a 40mm/ 1.5 inch island platform. Charlotte Olympia pumps have an almond toe, satin covered platform and heel, gold metal designer logo at sole, leather inner sole and comes with matching colored stockings with spider web insignia at calf.</p>]]></value> </textarea> <socialbookmarks identifier="00e1df62-828d-42f5-a1a6-a89d553d4934"> <value><![CDATA[1]]></value> </socialbookmarks> <relateditems identifier="64c188a6-cf2f-4895-8879-8b67a58b6780"/> </elements>'; // You figure out something here, if you can. // Start at http://php.net/refs.xml and SimpleXML is the easiest option. // Post back if you're falling flat on your face, or get more stuck! echo $url; Cheerio for now.
  16. DOM understands well-formed (and is quiet lenient with badly-formed) HTML just fine.
  17. PHPFreaks uses an army of insects, looking over your shoulder to see which posts you're reading, who then report back to the forum server via your wifi (or tapping into your modem directly). Sometimes they eat cookies, if the cookie jar is left open… they've got to eat something!
  18. Hi there, cssfreakie. Welcome to the land of PHP freakies
  19. You have multiple options (I won't list them all). 1. Use glob() which sorts the files in ascending alphabetical order, then reverse the array. 2. Use scandir() which also sorts the files in ascending alphabetical order, but does not allow filtering which files are returned (you want only PNG images). Then filter the array to get PNGs, then sort it. 3. Continue using readdir, but create an array of the PNG images instead of echoing. Then sort the array. Then echo each image. Which route do you think you'd like to follow?
  20. No it doesn't. $string = "word"; $string = explode('-', $string); echo $string[0]; // word
  21. Did you read the documentation for the class that you're using? You can restrict the objects returned from getBucket() by specifying a prefix. See http://undesigned.org.za/2007/10/22/amazon-s3-php-class/documentation#getBucket
  22. Which one? There are many! For what it's worth, if you use Amazon's own PHP library then you can call the AmazonS3 class's get_object_list() method with a prefix string, or regular expression, to get only the objects that you want. See http://docs.amazonwebservices.com/AWSSDKforPHP/latest/#m=AmazonS3/get_object_list
  23. I don't know about thorpe, but I think you're insane.
  24. You put your left boot in. You put your left boot out. You do a lot of shouting And you shake your fist about. You have a little smokey And you burn down the town. That's what it's all about!
  25. themistral, you could use a function like the one below to turn the associative nested array into a plain nested array. function unassoc(&$array) { // Re-index the array $array = array_values($array); // Call unassoc recursively for sub-arrays foreach ($array as &$val) { if (is_array($val)) { unassoc($val); } } } // Use it like this unassoc($data); echo $data[0][0];
×
×
  • 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.