Jump to content

ivytony

Members
  • Posts

    152
  • Joined

  • Last visited

    Never

Everything posted by ivytony

  1. I have tried to write the following messy code, and it works. But I am looking for improvements, if you guys can help me. <?php $seq = "MAHTSQHILTQSQTPSQPILVSQMASQWRESQ"; echo "Original sequence is: $seq\n"; // $stq_sites = count_stq($seq); //count the number of [s/T]Q sites $sq_sites = substr_count($seq, 'SQ'); $distri_sq = array(); // array container for all the distributions of SQ sites for($i = 0; $i < $sq_sites; $i++){ $needle = "SQ"; $length_needle = strlen($needle); $length_stack = strlen($seq); $pos = strpos($seq, $needle); // $pos += 1; if($pos){ $pos += $length_needle; //the position where the new stack will start $length_stack -= $pos; $seq = substr($seq, $pos, -1); echo "<br />new sequence is: $seq\t with position $pos\n "; if($i > 0) array_push($distri_sq, $pos); } } echo "<br />Size of array: ". sizeof($distri_sq) ."<br />"; echo "avaraged distance is: ". array_sum($distri_sq)/sizeof($distri_sq); ?>
  2. I want to search all the positions of the character combo 'SQ' and 'TQ' in this amino acid sequence: . After finding all the positions, I would also like to compute the distance between each occurrences. I appreciate your help.
  3. thanks, I think str_replace works! I also need to search for "SP" and "TP" sites in the protein sequence, how to do the search more efficiently? I want to equalize "S" with "T" in the search.
  4. but I also want to count the occurrences in the sequence string.
  5. I have a sequence that contains many amino acids (e.g. MATQSTDPEGTGSTTS.....), and I want to find both 'ST' and 'TS' in the sequence. I also want to print out the sequence with 'ST' and 'TS' highlighted in color and report the total number of the 'ST' and 'TS' sites found. pls help me a bit to start coding. thanks!
  6. I'd like to find related entries in MySQL database by looking for similar terms as the current article title. For example, the current article title is 'Giant Scale RC Hawker Sea Fury (HD)' and after using explode for the title, the key words will become 'Giant', 'Scale', 'RC', 'Hawker', 'Sea', 'Fury', and 'HD'. I want to find related entries in database that have one or more of the key words. I wonder how to do it effective? Thanks
  7. I am trying to create a database of Bible that allows people to query by chapter and/or verses. I have the entire bible in a txt file, formatted in this way: I would like to import the file to mysql and save the chapter #, verse # and the verse in three different columns. I wonder how I could possibly do this? Thanks
  8. I also use Apache 2.2.11 with PHP 5.2.8. weird
  9. exactly! PHP Version 5.2.8 Should I install the latest version of Zend Engine?
  10. phpinfo() shows: 1. Loaded Configuration File C:\php\php.ini 2. Loaded Modules: Here's the error message in apache error logs: I wonder what this means?
  11. tried everything, but still xdebug doesn't show up in phpinfo(). I am pretty sure that I am editing the right php.ini file.
  12. all right, I just did what you suggested here, but I still cannot see the 'xdebug' shown in my phpinfo.php output. any ideas? thanks
  13. I am using Apache + PHP 5.2.8 on my laptop installed with Windows Vista 32 and it works just fine. I have been trying to install XDebug since last night, but haven't got any luck getting it to work. Basically, I downloaded the .dll binary file (5.3 VC9) from http://www.xdebug.org/download.php, and put it in the PHP extension directory (C:\php\ext), then changed the php.ini to below: uncommented this line: added this block at the end of the file: I restarted my apache, but I still couldn't find the XDebug section in my phpinfo.php output. I wonder what else I need to do? Thanks in advance!
  14. I have a title like this 'Aero GP Al Ain - Live webcast of Air race and Air Show, a video from AirSportsTV. aero gp al ain, aero gp, live webcast, webcast, live' I want to delete the part shown in bold and keep the first half. However, the first half may be different in other titles, and the second half that I want to delete always starts with ', a video from' I wonder how to do this using wild card.
  15. Thanks! I was already able to get the title from the XML file, however, I am interested in fetching the value of duration in the below tag (in bold). the tag <media:content> is still located within the <item> and </item> tags. How do I get the value of duration? thanks
  16. Here's the XML file generated from MetaCafe API: http://www.metacafe.com/api/item/2348336 I would like to parse the XML file to get the 'duration="49"' part from the <media:content tag. However, the the following code doesn't work <?php $feedUrl = 'http://www.metacafe.com/api/item/2348336'; $rawFeed = file_get_contents($feedUrl); $xml = new SimpleXmlElement($rawFeed); foreach ($xml->channel->item as $item) { $content = $item->media->content; } echo $content;?> Could someone here give me a little help again pls?
  17. For example, here's a paragraph of text in HTML code: <a href="http://www.metacafe.com/watch/23483/cute_girl/"><img src="http://s1.mcstatic.com/thumb/2348336/9545650/4/directors_cut/0/1/cute_smart_girl.jpg" align="right" border="0" alt="Cute Smart Girl" vspace="4" hspace="4" width="134" height="78" /></a> <p> laugh and leave comment <br>Ranked <strong>4.46</strong> / 5 | 4995 views | I would like to extract the image link, 'laugh and leave comment', and the numbers 4.46 and 4995 from the above paragraph. I wonder if it's possible to do this with PHP.
  18. I'm trying to parse an XML file outputed by Metacafe.com API: http://www.metacafe.com/api/item/2348336 Below is my code: <?php class RSSParser { var $insideitem = false; var $tag = ""; var $title = ""; var $description = ""; var $link = ""; //var $video_details function startElement($parser, $tagName, $attrs) { if ($this->insideitem) { $this->tag = $tagName; } elseif ($tagName == "ITEM") { $this->insideitem = true; } } function endElement($parser, $tagName) { public $video_details = array(); if ($tagName == "ITEM") { /* printf("<p><b><a href='%s'>%s</a></b></p>", trim($this->link),htmlspecialchars(trim($this->title))); printf("<p>%s</p>", htmlspecialchars(trim($this->description))); */ $video_details["title"] = $this->title; $video_details["link"] = $this->link; $video_details["description"] = $this->description; $this->title = ""; $this->description = ""; $this->link = ""; $this->insideitem = false; return $video_details; } } function characterData($parser, $data) { if ($this->insideitem) { switch ($this->tag) { case "TITLE": $this->title .= $data; break; case "DESCRIPTION": $this->description .= $data; break; case "LINK": $this->link .= $data; break; } } } } $xml_parser = xml_parser_create(); $rss_parser = new RSSParser(); xml_set_object($xml_parser,&$rss_parser); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "characterData"); $fp = fopen("http://www.metacafe.com/api/item/2348336","r") or die("Error reading RSS data."); while ($data = fread($fp, 4096)) xml_parse($xml_parser, $data, feof($fp)) or die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); echo $video_details["title"]; fclose($fp); xml_parser_free($xml_parser); ?> But when I run it, I got a blank page. I wonder how to return the array $video_details in the function endElement. Or somewhere might be wrong?
  19. sorry, I should have made my question easier to understand. The PHP code in the particular page process.php doesn't have any security hole. The process.php page can get the youtube video details by providing a youtube video ID. However, I want to have this page be accessed exclusively by my own website 'domain2.com', while keeping others from using my page to get youtube video details. I think there must be someway to control the request access. ???
  20. I have a PHP file that processes the variables passed through a URL, for example: The PHP file name is: process.php Variables passed through url: $start and $number, (e.g. http://www.domain2.com/process.php?start=1&number=20) process.php uses a function to process these two variables. I would like to prevent people using this page to return values. I wonder how to limit the access only to my own website 'domain2.com'. Is there anyway to do this?
  21. I would like to integrate SMF with clip bucket and I wonder what would be the most critical part for the integration in general. Is it the cookie/session after a user logs in either SMF or clip bucket? or the user database table has to be synchronized or even both? Please shed some light, thanks
  22. thanks guys! the explode function works very well but what if the $url is 'youtube.com/path?arg=value#anchor' without the www part?
  23. I am able to get the 'domain' part from a domain like www.domain.com using below code. I wonder if there's any more efficient way to do this. Thanks <?php function str_between($string, $start, $end){ $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len); } $url = 'http://www.youtube.com/path?arg=value#anchor'; $domain = str_between($url, ".", "."); echo $domain; ?>
×
×
  • 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.