Page 1 of 1

strcat in php?

Posted: Fri Nov 21, 2008 1:16 am
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?

Re: strcat in php?

Posted: Fri Nov 21, 2008 2:31 am
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.

Re: strcat in php?

Posted: Fri Nov 21, 2008 2:36 am
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";
 
 
 

Re: strcat in php?

Posted: Fri Nov 21, 2008 3:55 am
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?!

Re: strcat in php?

Posted: Fri Nov 21, 2008 4:02 am
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)..

Re: strcat in php?

Posted: Fri Nov 21, 2008 4:09 am
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 :)