It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming PHP and MySQL Forum

how to make long string shorter

Moderator: Malcolm

how to make long string shorter

Postby nighthawk on Mon Sep 11, 2006 7:39 pm

Is there a php function that can make long string shorter, for example take only first 10 characters and delete the rest?

Or I will have to make my own function - maybe explode string into array and then take first 10 characters and convert them back to string.
User avatar
nighthawk
250+ Club
 
Posts: 420
Joined: Sun Jun 11, 2006 1:53 pm
Location: SFRJ

Postby webmaster on Mon Sep 11, 2006 7:59 pm

You can use substr like this:

[php]<?php
$var = "123451234512345";
echo substr($var, 0, 4);
?>[/php]

It should print out the first 10 characters (1234512345)
Make sure to check out our TNX Review and Link Vault Review
User avatar
webmaster
Site Admin
 
Posts: 2695
Joined: Tue Aug 17, 2004 1:07 pm
Location: Sweden

Postby nighthawk on Tue Sep 12, 2006 7:36 pm

Thank you
The Zeitgeist Movement
User avatar
nighthawk
250+ Club
 
Posts: 420
Joined: Sun Jun 11, 2006 1:53 pm
Location: SFRJ


Who is online

Users browsing this forum: No registered users and 0 guests