Jump to content

russthebarber

Members
  • Posts

    62
  • Joined

  • Last visited

Everything posted by russthebarber

  1. On looking up ucfirst() it seems that that only capitalises the first word in the string, not the first letter of every word....but in looking it up I found that I just need ucwords() on its own. So, thanks for the help. Problem solved!
  2. Hi, I have set up a simple function so that when a user enters a title in a php form, php gives the first letter of each word a capital letter. As follows: function caps($text){ $search_text=$text; $search_text=ucwords(strtolower($search_text)); $look_for = "(a"; $change_to = "(A"; $changed_text = str_replace($look_for, $change_to, $search_text); $search_text=$changed_text; $look_for = "(b"; $change_to = "(B"; $changed_text = str_replace($look_for, $change_to, $search_text); $search_text=$changed_text; $look_for = "(c"; $change_to = "(C"; //...etc...etc.. up to $look_for = "(z"; $change_to = "(Z"; $changed_text = str_replace($look_for, $change_to, $search_text); $search_text=$changed_text; return $search_text; } The trouble is, if I were to enter the following "The secret of DNA", my function would return "The Secret Of Dna" (removes the caps). Any ideas how to get around this would be most useful. Thanks in advance. Russ
  3. hi, i don't understand what the problem is with using 'include'. you will have no problem with your links using this method.
  4. I have another approach which is not exactly what you are looking for but might get you going in another direction. 1. make arrays of 10-word sequences. 2. then look for anywhere where array1(1,2,3) is the same as either 1,2,3 or 2,3,4 or 3,4,5 etc in another array. does that make sense? i am more clued up with mysql than php so i would dump the whole thing into a db and worlk with the data from there.
  5. $chars is set to 95. when i change to 45 or another value it makes no difference. i have just see your query on pattern searching. i may have some help for you in a minute or two.
  6. ....no, still the same problem. :'(
  7. Thanks Burtle. That's unfortunately made no difference though
  8. i am having to use a javascript function to make an html form 'submit' button look like a link. this is working fine on its own. the problem is when i combine this with some php (first) its putting the link on a separate line. can anyone see where the problem is in my code. if(strlen($str) > $chars) {echo end(array_reverse(explode("\n", wordwrap($str, $chars)))) . ' ...'; ?> <a href="javascript:getsupport('<? echo $row ['id']; ?>')"><div style="color:#FFFFFF; font-size:9px">more</div></a> ///end of relevant code. there is more code at the bottom if this is not clear. i'm getting this: bla bla bla bla bla... more i should be getting this: bla bla bla bla bla...more ///here's some more of the code <table border="0" align="left" cellpadding="0" cellspacing="0" height="122" width="494" background="img/bgbox2_494x1.jpg"> <tr> <td height="11"></td> </tr> <form name="supportform" method="post" action="newsmore.php"> <input type="hidden" name="id" /> <? $counter="0"; while($row = mysql_fetch_array($result)) { $counter=$counter+1; if($counter == "1") {$bg="img/bgbox2_494x1.jpg";} if($counter == "2") {$bg="img/bgbox2_494x1b.jpg";} if($counter == "3") {$bg="img/bgbox2_494x1.jpg";} if($counter == "4") {$bg="img/bgbox2_494x1b.jpg";} if($counter == "5") {$bg="img/bgbox2_494x1.jpg";} ?> <tr> <td background="<? print("$bg"); ?>" height="20"><div style="color:#FFFFFF; margin-left:15px; margin-right:15px; font-family:Arial, Verdana, Helvetica, sans-serif; font-size:9px"> <? $str = $row['entry_date'] . $spacer . $row['maintext']; if(strlen($str) > $chars) {echo end(array_reverse(explode("\n", wordwrap($str, $chars)))) . ' ...'; ?> <a href="javascript:getsupport('<? echo $row ['id']; ?>')"><div style="color:#FFFFFF; font-size:9px">more</div></a> <? } else {echo $str . '... <a href="#">more</a>';} ?> </div> </td> </tr> </form> <? } ?> <tr><td height="11"></td></tr> </table>
  9. Thanks to everyone who replied here. That's helped me a lot.
  10. hi, does anyone know how to use PHP to take the first few words of a text and limit them? i have seen this in many news sites where the news story headline reads like "woman found in obama's bedroom today at....... read more. ('read more' is a link) what i am looking for is something that says i will take the first 100 characters of the entry and then print "...read more" as a link to the full story. thanks
  11. The BCC option looks good. Many thanks for your time. ;-)
  12. Hello. When sending an email from my email client, I can send to a group for example named "mailing list". By doing this i can hide all the email addresses from my other mailing list members as the mail is sent to "mailing list" and not to a list of email addresses separated by commas. Does anybody know how to do this with PHP so when people receive a mail the addresses of all the other mailing list members are hidden? Thanks in advance. Here's the code i am using for PHP to send an HTML mail: <?php //define the receiver of the email $to = '[email protected]'; //define the subject of the email $subject = 'Test HTML email'; //create a boundary string. It must be unique //so we use the MD5 algorithm to generate a random hash $random_hash = md5(date('r', time())); //define the headers we want passed. Note that they are separated with \r\n $headers = "From: [email protected]\r\nReply-To: [email protected]"; //add boundary string and mime type specification $headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\""; //define the body of the message. ob_start(); //Turn on output buffering ?> --PHP-alt-<?php echo $random_hash; ?> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hello World!!! This is simple text email message. --PHP-alt-<?php echo $random_hash; ?> Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: 7bit <h2>Hello World!</h2> <p>This is something with <b>HTML</b> formatting.</p> --PHP-alt-<?php echo $random_hash; ?>-- <? //copy current buffer contents into $message variable and delete current output buffer $message = ob_get_clean(); //send the email $mail_sent = @mail( $to, $subject, $message, $headers ); //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" echo $mail_sent ? "Mail sent" : "Mail failed"; ?>
×
×
  • 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.