Jump to content

[SOLVED] string editing..


Michdd

Recommended Posts

Use substr or use pathinfo

 

$file = '546.gif';

echo substr($file, -4); // returns 546

// OR use the following PHP 5.2.x ONLY
$info = pathinfo($file);
echo $info['filename'];

Thanks, I just thought of another way.. I couldn't I just use explode()l and explode by the "."? Then use the first element of the array?

 

Edit: Just to let you know yours does the opposite. It returns ".gif". I used:

 

$id = explode(".", $file);

echo $id[0];

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.