note 87769 modified in function.strrpos by danbrown

From: Date: Sat, 20 Dec 2008 16:38:21 +0000
Subject: note 87769 modified in function.strrpos by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-148384@lists.php.net to get a copy of this message
I needed to check if a variable that contains a generated folder name based on user input had a trailing slash. This did the trick: <?php // Detect and remove a trailing slash $root_folder = ((strrpos($root_folder, '/') + 1) == strlen($root_folder)) ? substr($root_folder, 0, - 1) : $root_folder; ?> --was-- I needed to check if a variable that contains a generated folder name based on user input had a trailing slash. This did the trick: // Detect and remove a trailing slash $root_folder = ((strrpos($root_folder, '/') + 1) == strlen($root_folder)) ? substr($root_folder, 0, - 1) : $root_folder; http://php.net/manual/en/function.strrpos.php

« previous php.notes (#148384) next »