I am not perfect at this stuff, as I still have a lot to leatn, But I do a lot of work with PHP on a regular basis, so please ask if there is anything that I can help with.
Let me helpI know a bit about PHP if you need it
Page 1 of 1
4 Replies - 1421 Views - Last Post: 04 May 2001 - 08:08 PM
#1
Let me help
Posted 02 May 2001 - 06:56 PM
Replies To: Let me help
#2
Re: Let me help
Posted 03 May 2001 - 04:31 AM
How can I completely delete a variable and its contents?
#3
Re: Let me help
Posted 03 May 2001 - 04:57 PM
How can I determine the number of characters in a string?
#4
Re: Let me help
Posted 04 May 2001 - 06:59 PM
unset($GLOBALS['variableToDelete']);
within the function.
Now for your next question. PHP strings are arrays, but the array functions don't seem to want to all work with strings. So your first step is to turn the string into an array. After turning it into an array, you can then call count and get the number of characters. The code might look as follows:
$chars = preg_split("//", $string_to_manipulate);
$num_of_chars = count($chars);
Then use $num_of_chars for whatever you are looking to do with the number.
Tsmoke
#5
Re: Let me help
Posted 04 May 2001 - 08:08 PM
$file = fopen ("news/news.txt", "r");
$news = fread ($file, filesize("news/news.txt"));$newssplit = preg_split("//", $news);
$newschars = count($newssplit);
if($newschars >= 600){
$news = substr($news, 0, 600);
$news = "$news... [<a href="news">more</a>]";
print $news;
}else{
print $news;
}
fclose ($file);
Thanks for the preg_split tip. I'll try unset tomorrow.
|
|

New Topic/Question
This topic is locked




MultiQuote



|