Jump to content

[SOLVED] substring


Asday

Recommended Posts

What you're looking for is substr

<?php
      $s = 'http://www.php.net';
      if (substr($s, strlen('http://'))) {
            //code ... it starts with http:// ... so what to do?
      }else {
            //code ... it doesn't start with http:// ... so what to do?
      }
?>

Link to comment
https://forums.phpfreaks.com/topic/59624-solved-substring/#findComment-296270
Share on other sites

What you're looking for is substr

<?php
      $s = 'http://www.php.net';
      if (substr($s, strlen('http://'))) {
            //code ... it starts with http:// ... so what to do?
      }else {
            //code ... it doesn't start with http:// ... so what to do?
      }
?>

 

Thanks!  That worked (Had to fiddle with it to get it to work with my existing code)

 

<?php
if (($_FILES["file"]["type"] == "image/gif")
// ...
&& ($_FILES["file"]["name"] !== (substr($_FILES["file"]["name"], strlen("http://")))))
{
  // upload
}
else
{
  echo "Sod off.";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/59624-solved-substring/#findComment-296277
Share on other sites

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.