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