1
<?php echo $entry->field('logo')->generate(); ?>

This gives me the path of my images, but I want to cut the last 3 letters from the back(the suffix).

The normal function is:

<?php
rest = substr("Test", 0, -1);
?>

But I don't get an output with this:

<?php
$rest = substr($entry->field('logo')->generate(), 0, -1); 
?>
fr3d
  • 665
  • 1
  • 5
  • 17

1 Answers1

3

You have to take the value in a variable

$var = $entry->field('logo')->generate();

Then you put the substr function on the variable

$rest = substr($var, 0, -1);
Maninderpreet Singh
  • 2,569
  • 2
  • 17
  • 31
WebInsight
  • 307
  • 2
  • 20
  • No problemo friend.Anytime – WebInsight Apr 06 '16 at 11:53
  • I've got another question, my image path looks like this: assets/images/b/logo.png. is it possible to cut the path to the third "/" so that I only got the filesname? – fr3d Apr 06 '16 at 12:31
  • Please follow this link http://www.w3schools.com/php/func_string_substr.asp to do what you exactly want to do with your data – WebInsight Apr 06 '16 at 12:35
  • The problem is, that the path of the files is not always 10 characters long. – fr3d Apr 06 '16 at 12:36
  • For your problem can see this http://stackoverflow.com/questions/1418193/how-to-get-file-name-from-full-path-with-php – WebInsight Apr 06 '16 at 12:38