note 101863 modified in function.substr by danbrown

From: Date: Fri, 14 Jan 2011 17:18:14 +0000
Subject: note 101863 modified in function.substr by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-175750@lists.php.net to get a copy of this message
If you want to have a string BETWEEN two strings, just use this function: <?php function get_between($input, $start, $end) { $substr = substr($input, strlen($start)+strpos($input, $start), (strlen($input) - strpos($input, $end))*(-1)); return $substr; } //Example: $string = "123456789"; $a = "12"; $b = "9"; echo get_between($string, $a, $b); //Output: //345678 ?> --was-- If you want to have a string BETWEEN two strings, just use this function: function get_between($input, $start, $end) { $substr = substr($input, strlen($start)+strpos($input, $start), (strlen($input) - strpos($input, $end))*(-1)); return $substr; } //Example: $string = "123456789"; $a = "12"; $b = "9"; echo get_between($string, $a, $b); //Output: 345678 http://php.net/manual/en/function.substr.php

« previous php.notes (#175750) next »