Page 1 of 1

String length...

Posted: Sun Jul 03, 2005 1:15 pm
by icarpenter
Hi

I am trying to return the first three letters from a string which has an unknown length...

Does anyone know of suitable function for this?

Thanks Ian.

subject: String length...

Posted: Sun Jul 03, 2005 1:23 pm
by icarpenter
Don't worry I haveit...

I used.

Code: Select all

$test  = sprintf("%0.3s",$var);
echo $test;
Rgds Iantf("%0.3s",$var);
echo $test;


Rgds Ian85]

Rgds Ian = sprintf("%0.3s",$var);
echo $test;


Rgds Ianit...

I used.

Code: Select all

$test  = sprintf("%0.3s",$var);
echo $test;
Rgds Ianrintf("%0.3s",$var);
echo $test;


Rgds Ianhp]
$test = sprintf("%0.3s",$var);
echo $test;


Rgds Ianit...

I used.

Code: Select all

$test  = sprintf("%0.3s",$var);
echo $test;
Rgds Ian1]
$test = sprintf("%0.3s",$var);
echo $test;


Rgds Ianmp;quote;,$var);
echo $test;


Rgds Ian Ianmp;quote;%0.3s",$var);
echo $test;


Rgds Ianit...

I used.

Code: Select all

$test  = sprintf("%0.3s",$var);
echo $test;
Rgds Ianuote;,$var);
echo $test;


Rgds Ianit...

I used.

Code: Select all

$test  = sprintf("%0.3s",$var);
echo $test;
Rgds Ianest;


Rgds Ian sprintf("%0.3s",$var);
echo $test;


Rgds Iananamp;quote;,$var);
echo $test;


Rgds Ianit...

I used.

Code: Select all

$test  = sprintf("%0.3s",$var);
echo $test;
Rgds Ian
$test = sprintf("%0.3s",$var);
echo $test;


Rgds Ian

Posted: Sun Jul 03, 2005 3:30 pm
by timvw
Virtually every language has a function substring for that...

http://www.php.net/substr