Jump to content

maddogandnoriko

Members
  • Posts

    63
  • Joined

  • Last visited

    Never

Posts posted by maddogandnoriko

  1. I am writing a script that converts php pages to html pages for mobile devices with no net connection. I have an multi-dimensional array of urls and their replacement values:

     

    $links=array($phpURL,$fixedURL);

     

    Can I break this into two arrays, one containing all $phpURL's and another array containing all $fixedURL's?

     

     

    Here is what I am ultimately trying to do, if there is a cleaner way of doing it by all meansplease let me know.

    $text=str_replace($phpURLarray, $fixedURLarray, $text);

     

     

    Thank you once again for rescuing me from myself,

                                                                              Todd

     

  2. Can I get the third element of an array regardless of it's key name? For example I have an $example array:

     

    Array ( [3] => European_SIB_Association [4] => andrew1.jpg [5] => andrew2.jpg [6] => andrew3.jpg [7] => andrew4.jpg [8] => artem )

     

    How can I get the second element even though it is named four?

     

    Thank you,

                    Todd

  3. I have some pages that have pretty basic php in them to include common sidebars and the site title and footer etc. I am trying to generate static html from said pages for transfer to a portable device w/o internet connection. I was using the following function, but it is just copying the php files, when I want to copy the generated html.

     

    Thank you

                    Todd

     

      function wwwcopy($link,$file){
    	$content='';
    	$fp = @fopen($link,"r");
    	while(!feof($fp)){
    		$content.= fread($fp,1024);
    	}
        fclose($fp);
        $content=replace_filenames($content);
        $fp2 = @fopen($file,"w");
        fwrite($fp2,$content);
        fclose($fp2);
      }
    

  4. I have an xml file loaded into a simplexml object. The xml has a "ö" in it and is getting garbled in the simplexml object. Here is my test code:

     

    <?php 
          $seriesURL='http://www.thetvdb.com/api/GetSeries.php?seriesname=krod';
          echo 'SeriesURL:'.$seriesURL.'<br><br>';
          $data = simplexml_load_file($seriesURL);
          
          echo '<br><br>'. ($data->Series->SeriesName);
    ?>
    

     

    The resulting Series Name is: Kröd Mändoon and the Flaming Sword of Fire

     

  5. I have an xml page loaded into a simplexml object. I am trying to create an array of SeriesNames from the simple xml object to pass to smarty. When I add a SeriesName to the $shows array, it adds it as an object not as the elements text value.

     

    PHP:

          $counter=0;
          $shows=array();
          $seriesURL='http://www.thetvdb.com/api/GetSeries.php?seriesname=bones';
          $data = simplexml_load_file($seriesURL);
          foreach($data->Series as $series){
            $shows["$counter"]['name']=$series->SeriesName;
            $counter++;
          }
    

     

    The XML:

    <Data>
    −
    <Series>
    <seriesid>75682</seriesid>
    <language>en</language>
    <SeriesName>Bones</SeriesName>
    <banner>graphical/75682-g3.jpg</banner>
    −
    <Overview>
    Dr. Temperance Brennan is a highly skilled forensic anthropologist at the Jeffersonian Institute in Washington, DC. When the standard methods of identifying a body are useless - when the remains are so badly decomposed, burned or destroyed that CSI gives up - law enforcement calls in Brennan for her uncanny ability to read clues left behind in the victim's bones.
    
    Special agent Seeley Booth of the FBI's Homicide Investigations Unit is the exception. A former Army sniper, Booth mistrusts science and scientists - the "squints," as he calls them -- who pore over the physical evidence of a crime. 
    </Overview>
    <FirstAired>2005-09-13</FirstAired>
    <IMDB_ID>tt0460627</IMDB_ID>
    <zap2it_id>SH754201</zap2it_id>
    <id>75682</id>
    </Series>
    −
    <Series>
    <seriesid>76818</seriesid>
    <language>en</language>
    <SeriesName>Hearts and Bones</SeriesName>
    −
    <Overview>
    Hearts and Bones series one is a seven-part one-hour drama which explores the lives, loves and careers of a group of friends from Coventry who all move to London.  Emma is in a seven year relationship with Mark Rose, with whom she has a son Sam. She marries him although she loves his brother Rich-a butcher.  Rich lives with his girlfriend Louise who is a hairdresser but he finds the temptation of a dalliance with Emma hard to resist especially when his relationship with Louise comes under strain when Louise's mother becomes ill.  There is also Emma's best pal Amanda who's single since splitting up with her investment banker boyfriend Michael; Romance novel writer Sinead is besotted with Mark but turns to the Internet for love when he marries Emma.  Series two picks up the story three months on.  Mark has left and 
    Emma and Rich haven't spoken since their affair.  Emma is being shunned by Michael and Sinead. Michael is once more estranged from Amanda.  Only Emma, Amanda and Louis
    </Overview>
    <FirstAired>2000-07-01</FirstAired>
    <id>76818</id>
    </Series>
    −
    <Series>
    <seriesid>70881</seriesid>
    <language>en</language>
    <SeriesName>Fitz and Bones</SeriesName>
    <FirstAired>1981-10-01</FirstAired>
    <id>70881</id>
    </Series>
    </Data>

     

    Here is the array I end up with including the unwanted simplexml objects:

    Array ( [0] => Array ( [name] => SimpleXMLElement Object ( [0] => Bones ) ) [1] => Array ( [name] => SimpleXMLElement Object ( [0] => Hearts and Bones ) ) [2] => Array ( [name] => SimpleXMLElement Object ( [0] => Fitz and Bones ) ) )  

  6. It is happening when I import it into the xml object, I think. Sorry to have muckec this thread up so bad......

     

    For this xml url:http://www.thetvdb.com/api/GetSeries.php?seriesname=krod

     

    The xml:

    <Data>
    −
    <Series>
    <seriesid>88631</seriesid>
    <language>en</language>
    <SeriesName>Kröd Mändoon and the Flaming Sword of Fire</SeriesName>
    <banner>graphical/88631-g2.jpg</banner>
    −
    <Overview>
    The series follows a reluctant hero named Kröd Mändoon. The often underconfident freedom fighter is the last great hope in the struggle against an evil ruler known as Chancellor Dongalor. To help in his fight, Kröd has assembled a band of remarkably useless fighters. Together, they must overcome a variety of evil obstacles in a quest to save their world. 
    </Overview>
    <FirstAired>2009-04-09</FirstAired>
    <id>88631</id>
    </Series>
    </Data>

     

    the simplexml object(as print_r'd):

    Array ( [series] => Array ( [seriesid] => 88631 [language] => en [seriesName] => Kröd Mändoon and the Flaming Sword of Fire [banner] => graphical/88631-g2.jpg [Overview] => The series follows a reluctant hero named Kröd Mändoon. The often underconfident freedom fighter is the last great hope in the struggle against an evil ruler known as Chancellor Dongalor. To help in his fight, Kröd has assembled a band of remarkably useless fighters. Together, they must overcome a variety of evil obstacles in a quest to save their world. [FirstAired] => 2009-04-09 [id] => 88631 ) )

  7. I am sorry. My problem occurs much earlier than inserting it into the db. Could someone point me in the direction of an article or tutorial for working with these types of characters?

     

    Thank you

                    maddogandnoriko

  8. I am building a Television site and have imported an xml page into a simple xml object and put the results into an sql table. My problem is with the "ö" character, although I suspect it will affect other similar characters. When I get the result from the db it is not "ö", but is "ö". I suspect it is my db setup as the row it is in is set to latin1_swedish_ci collation. Should it be something else? I know strictly this is not a php question but sql and php are so closely linked I figured someone here would be able to answer this.

     

    Thank you for your time,

    maddogandnoriko

  9. I have a function that downloads an image via curl. If the image is not available the page is an html page stating the image is not available. How can I check to see if the url to download is an image or the html page?

     

    Thank you,

                maddogandnoriko

     

    function LoadImageCURL($save_to){
    	$ch = curl_init($this->source);
    	$fp = fopen($save_to, "wb");
    
    	// set URL and other appropriate options
    	$options = array(CURLOPT_FILE => $fp,
    									 CURLOPT_HEADER => 0,
    									 CURLOPT_FOLLOWLOCATION => 0,
    									 CURLOPT_TIMEOUT => 60); // 1 minute timeout (should be enough)
    
    	curl_setopt_array($ch, $options);
    
    	$result=curl_exec($ch);
    	curl_close($ch);
    	fclose($fp);
    	return $result;
    }
    
    

  10. I have an xml page loaded into a simplexml object, and have used xpath as to just work on the episode tags.

     

    $episode_data=$this->xml->xpath("/Data/Episode[id=.$tvdbID.]");

     

    When I echo the value of 'SeasonNumber' ($episode->SeasonNumber) I get a number as expected. But if I add $episode->SeasonNumber to an array:

    $this->seasonList[] = (int)$episode->SeasonNumber[0];

     

    It adds a simplexml object to the array not the number as echoed before, in the end I am trying to end up with a simple array of season #'s.

     

    I have tried to include tenough info but not sure.

     

    Thank you for any help,

     

      maddogandnoriko

  11. I have a function that downloads an image. Is there a way to determine if it is actually an image before downloading it? If the image is non existant there is an html page and currently the function downloads that too, which I don't need

     

     

    Thank you much

                            maddogandnoriko

     

     

    The error html is:

    <html><BODY><TITLE>This is a banner mirrors site for thetvdb.com</TITLE>
    
    <H2>The page your requested does not exist.  Please check  
    <A HREF="http://www.thetvdb.com">thetvdb.com</A> for more information.
    </H2>
    </BODY>
    </HTML>
    

     

     

    the function

    function LoadImageCURL($save_to){
    	$ch = curl_init($this->source);
    	$fp = fopen($save_to, "wb");
    
    	// set URL and other appropriate options
    	$options = array(CURLOPT_FILE => $fp,
    									 CURLOPT_HEADER => 0,
    									 CURLOPT_FOLLOWLOCATION => 1,
    									 CURLOPT_TIMEOUT => 60); // 1 minute timeout (should be enough)
    
    	curl_setopt_array($ch, $options);
    
    	$result=curl_exec($ch);
    	curl_close($ch);
    	fclose($fp);
    	return $result;
    }
    

     

×
×
  • 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.