Reviews, updates and in depth guides to your favourite mobile games - AppGamer.com
|
|
PHP: Limit Length |
Page: 1 | Reply |
Jul 28th 2001 | #10458 Report |
Member since: Mar 18th 2001 Posts: 1452 |
This isn't my code, so I'm wondering how I can limit the title to a certain length of characters (it's a news grabber). [code]$items = 0; $time = split(" ", microtime()); srand((double)microtime()*1000000); $cache_time_rnd = 300 - rand(0, 600); if ( (!(file_exists($cache_file))) || ((filectime($cache_file) + $cache_time - $time[1]) + $cache_time_rnd < 0) || (!(filesize($cache_file))) ) { $fpread = fopen($backend, 'r'); if(!$fpread) { // echo "$errstr ($errno) \n"; // exit; } else { $fpwrite = fopen($cache_file, 'w'); if(!$fpwrite) { // echo "$errstr ($errno) \n"; // exit; } else { while(! feof($fpread) ) { $buffer = ltrim(Chop(fgets($fpread, 256))); if ($buffer == "%%") { $title = ltrim(Chop(fgets($fpread, 256))); $link = ltrim(Chop(fgets($fpread, 256))); $date = ltrim(Chop(fgets($fpread, 256))); $time = ltrim(Chop(fgets($fpread, 256))); $submit_handle = ltrim(Chop(fgets($fpread, 256))); $submit_email = ltrim(Chop(fgets($fpread, 256))); if (($title != "") && ($items < $max_items)) { fputs($fpwrite, "$link_prefix<A HREF=\"http://www.url.com$link\" TARGET=\"$target\">$title</A>$link_postfix"); $items++; } } } } fclose($fpread); } fclose($fpwrite); } if (file_exists($cache_file)) { include($cache_file); }[/code] |
Reply with Quote Reply |
Jul 28th 2001 | #10459 Report |
Member since: Jun 30th 2001 Posts: 447 |
Take a look at the substr() function in the PHP manual. It will do what you want.
|
Reply with Quote Reply |
Jul 28th 2001 | #10461 Report |
Member since: Mar 18th 2001 Posts: 1452 |
edit: Nevermind. Finally got it doing what I wanted it to do.
|
Reply with Quote Reply |
Page: 1 | Back to top |
Please login or register above to post in this forum |
© Web Media Network Limited. All rights reserved. No part of this website may be reproduced without written permission. Photoshop is a registered trademark of Adobe Inc.. TeamPhotoshop.com is not associated in any way with Adobe, nor is an offical Photoshop website. |