strcat in php?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dialla123
Forum Newbie
Posts: 2
Joined: Fri Nov 21, 2008 1:12 am

strcat in php?

Post by dialla123 »

Hello All,
I want to know if there is a function in php that does similar job of the strcat function in C!!
i want to declare a variable $data and concatenate data in it? How is this done in php

I have another question about the function sleep(), i am using php 5.2.5 but this function doesnt work, does anyone knows why?
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: strcat in php?

Post by Mark Baker »

I want to know if there is a function in php that does similar job of the strcat function in C!!
i want to declare a variable $data and concatenate data in it? How is this done in php

Code: Select all

 
$data = 'Hello';
 
$data .= ' ';
$data = $data.'World';
 
I have another question about the function sleep(), i am using php 5.2.5 but this function doesnt work, does anyone knows why?
No, and it works perfectly on a wide range of platforms and PHP versions that I'm using.
More details might help.... e.g. how do you know it's not working, what does it do, etc.
User avatar
xpgeek
Forum Contributor
Posts: 146
Joined: Mon May 22, 2006 1:45 am
Location: Kyiv, Ukraine
Contact:

Re: strcat in php?

Post by xpgeek »

dialla123 wrote:Hello All,
I have another question about the function sleep(), i am using php 5.2.5 but this function doesnt work, does anyone knows why?
Try this, if it dosn't hep pls show you example of code:

Code: Select all

 
 
// current time
echo date('h:i:s') . "\n";
 
// sleep for 10 seconds
sleep(10);
 
// wake up !
echo date('h:i:s') . "\n";
 
 
 
dialla123
Forum Newbie
Posts: 2
Joined: Fri Nov 21, 2008 1:12 am

Re: strcat in php?

Post by dialla123 »

Thank you very much guys for your help!
the function sleep() is working now!

Anyway, i have another question about php, lets say i have a string of charachters, eg. $data = "AAFCGDS"

There is a function in C language getc(), that returns one character of the string and move to the next charachter.
Is there a function in php that does the same thing?!
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: strcat in php?

Post by onion2k »

No, but there are plenty of alternatives. substr() with a loop strlen() times for example, or you can treat a string like an array of characters (eg $string[0] returns the first character)..
User avatar
xpgeek
Forum Contributor
Posts: 146
Joined: Mon May 22, 2006 1:45 am
Location: Kyiv, Ukraine
Contact:

Re: strcat in php?

Post by xpgeek »

dialla123 wrote:Thank you very much guys for your help!
the function sleep() is working now!

Anyway, i have another question about php, lets say i have a string of charachters, eg. $data = "AAFCGDS"

There is a function in C language getc(), that returns one character of the string and move to the next charachter.
Is there a function in php that does the same thing?!
In much cases you don't need it!
But, you can use for to loop through characters accessing by index $data[$i];
Or write you own getc :)
Post Reply