writer
Members-
Posts
50 -
Joined
-
Last visited
Never
Everything posted by writer
-
[SOLVED] Printing stdClass objects from an array
writer replied to writer's topic in PHP Coding Help
Nevermind! Got it all worked out -
I've got this massive amount of data coming from a WSDL that produces movie theaters and times. It's for an open-source local news site that I'm going to be handing out to struggling newspapers I'm having trouble parsing this, or printing it, in the ways that I've learned so far in my nascent PHP career -- so I'd like to ask you guys: How do you print elements individual elements when the print_r($variable) command turns out like this? I wish it was like this: echo $results[0][theater]; But that produces this error: Fatal error: Cannot use object of type stdClass as array in /home/taylorwb/public_html/localmost/movies/test.php on line 9 Here's what an individual array element looks like: stdClass Object ( [Theater] => Array ( [0] => stdClass Object ( [Name] => CineArts at Palo Alto Square [Address] => 3000 El Camino Real, Bldg. #6, Palo Alto, CA [Movies] => stdClass Object ( [Movie] => Array ( [0] => stdClass Object ( [Rating] => PG-13 [Name] => Reprise [RunningTime] => 1 hr 43 mins [showTimes] => 1:30pm | 4:10pm | 7:00pm | 9:40pm ) [1] => stdClass Object ( [Name] => The Visitor [showTimes] => 2:00pm | 4:30pm | 7:10pm | 9:35pm ) ) ) )
-
Saving a file locally, but comparing it to existing file first
writer replied to writer's topic in PHP Coding Help
At the heart of the matter: Can I use fopen() to compare two documents? -
I'm using the following code to copy an XML feed locally, but I'd like it to first check the remote file to see if it's the same as the original file... if so, I don't need to copy it again. <?php $content = $_POST['content']; $file = $_POST['fileName']; $content = stripslashes($content); $writeFile = fopen($file, "w"); if(fwrite($writeFile, $content)) { echo $content; } else { echo "Error writing to file"; } fclose($writeFile); ?>
-
When trying to use the code below, I'm getting an error. From Googling the error, I can tell that I have to write to a relative path, but I'm not familiar with fwrite() and need some help figuring out where. Error: Warning: fopen(http://www.washingtonpost.com/wp-dyn/rss/print/index.xml1210815958) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/taylorwb/public_html/aheds/WaPoScrape.php on line 7 Warning: fwrite(): supplied argument is not a valid stream resource in /home/taylorwb/public_html/aheds/WaPoScrape.php on line 8 Warning: fclose(): supplied argument is not a valid stream resource in /home/taylorwb/public_html/aheds/WaPoScrape.php on line 9 Code: <?php $path = "http://www.washingtonpost.com/wp-dyn/rss/print/index.xml"; $xml = file_get_contents($path); echo $xml; $name = substr($path, strpos("/", $path), strlen($path)); $file = fopen($name . time(), "w"); fwrite($file, $xml); fclose($file); ?>
-
Setting up a script to scrape and copy an XML feed
writer replied to writer's topic in PHP Coding Help
Thanks for the code! Hmm. Any way around this? Warning: fopen(http://www.dapper.net/RunDapp?dappName=TheDrudgeReportRSS&v=1&applyToUrl=http%3A%2F%2Fwww.drudgereport.com1210792822) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/taylorwb/public_html/aheds/scrape.php on line 6 Warning: fwrite(): supplied argument is not a valid stream resource in /home/taylorwb/public_html/aheds/scrape.php on line 7 Warning: fclose(): supplied argument is not a valid stream resource in /home/taylorwb/public_html/aheds/scrape.php on line 8 -
Setting up a script to scrape and copy an XML feed
writer replied to writer's topic in PHP Coding Help
I take it by your tone that there's a really easy way to copy an XML file? -
I'm wondering if there's a way to copy remote XML data using a script with a cronjob put on it. Has anyone ever seen something like this?
-
Is there an easier way to work with unix timestamps?
writer replied to writer's topic in PHP Coding Help
Followup: I can figure out Tuesday (find current Tuesday and count back) ... but can anyone help me figure out how to establish the first and last day's of the month? -
I'd like to do something similar. It sounds like there's a lot to it.
-
I'm having a lot of trouble wrapping my head around PHP's mktime function. I've got a a few difficult tasks (for example, pull all records filed on a Tuesday this year) and was wondering if there's a class library out there somewhere that can cut down my development time. Anyone know of an easier way to work with unix timestamps in PHP?
-
Wow, thanks Barand! Now how would I implement this? My guess: $n = new knack ($cap, $start)
-
i need this code to be this one , but work. That cracked me up.
-
Not sure how you're going to solve this: To get the background color, you need to use a:active, but you can only have one link active at a time.
-
I should be able to get an approx. answer if I can convert this to PHP: int knack(int cap, int start) { for(int i=start, max=0;i<N;i++) { int space=cap-item[i].size; if(space >= 0) { int t = knack(space, i+1)+item[i].val; if(t>max) { max=t; } } } return max; }
-
Top two articles when I stopped by: 1. Simple but interesting 2. Long but wierd
-
Yeah, I did a surface-level Google dive and found nothing. As soon as I found explode() I felt like an idiot. Thanks for the help.
-
Aha! A reply! I've heard of it being done at an academic level using JS, but at the time didn't have any programming knowledge.
-
I'd like to create a simple input form (field + submit button) that takes a comma separated list of locations (Paris, Hungary, Prague, etc.), strips the comma and turns the answers into an array ( $ar_locations = (1->Paris, 2->Hungary... etc.) ). Any idea of some resources with which I can do this?
-
Why sorry? Sounds like a good thing to me!
-
Vanilla does everything so well that I don't know why you're messing around with a custom build. But if you check out how they do it in their source, you might be able to figure out how to emulate it.
-
It could be that the script can't handle the space in your image title (perhaps "Picture_043.jpg" would work). Maybe you need to echo it out in ASCII? <img src="imageresize.php?maxsize=xxx&source=images/Picture 043.jpg" border=0 />
-
Read up on $_GET and $_POST. They more-or-less do the same thing, and are probably what you're looking for.