Let me help

I know a bit about PHP if you need it

Page 1 of 1

4 Replies - 1531 Views - Last Post: 04 May 2001 - 08:08 PM Rate Topic: -----

#1 tsmoke  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 50
  • Joined: 20-April 01

Let me help

Posted 02 May 2001 - 06:56 PM

Need a hand with some PHP stuff? I am here and willing to help. I am familiar with mySQL for database, so if you need a hand with that I may be able to help. Other DB's I'm not so sure of, but I may be able ot help with general SQL commands.

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.

Is This A Good Question/Topic? 0
  • +

Replies To: Let me help

#2 Paradox  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 432
  • Joined: 03-March 01

Re: Let me help

Posted 03 May 2001 - 04:31 AM

What exactly does 'unset' do?
How can I completely delete a variable and its contents?
Was This Post Helpful? 0
  • +
  • -

#3 Paradox  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 432
  • Joined: 03-March 01

Re: Let me help

Posted 03 May 2001 - 04:57 PM

One more question-
How can I determine the number of characters in a string?
Was This Post Helpful? 0
  • +
  • -

#4 tsmoke  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 50
  • Joined: 20-April 01

Re: Let me help

Posted 04 May 2001 - 06:59 PM

unset does delete a variable and it's content's. The problem with this is that if you are trying to unset a global variable inside of a function. If you you unset, it will only unset the variable that is local to the function. If you wish to delete global variables inside of a function, you would have to use:
    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

Was This Post Helpful? 0
  • +
  • -

#5 Paradox  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 432
  • Joined: 03-March 01

Re: Let me help

Posted 04 May 2001 - 08:08 PM

Whoo hoo! I finished my little script that cuts a news article short, and provides a link to view the rest of it:
$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.

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1