String length...

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
User avatar
icarpenter
Forum Commoner
Posts: 84
Joined: Mon Mar 07, 2005 8:12 am
Location: Kent, England

String length...

Post 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.
User avatar
icarpenter
Forum Commoner
Posts: 84
Joined: Mon Mar 07, 2005 8:12 am
Location: Kent, England

subject: String length...

Post 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
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Virtually every language has a function substring for that...

http://www.php.net/substr
Post Reply