We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 27a096c commit 2403f40Copy full SHA for 2403f40
framework/helpers/CString.php
@@ -19,7 +19,8 @@
19
* humanize
20
* plural
21
* isSerialized
22
- *
+ * shortenUrl
23
+ *
24
*/
25
26
class CString
@@ -237,4 +238,17 @@ public static function isSerialized($string)
237
238
239
return false;
240
}
241
+
242
+ /**
243
+ * Returns shorten URL
244
+ * @param string $url
245
+ * @param int $len1
246
+ * @param int $len2
247
+ * @return string|string[]|null
248
+ */
249
+ public static function shortenUrl($url = '', $len1 = 0, $len2 = 0)
250
+ {
251
+ return preg_replace("/(?<=.{{$len1}})(.+)(?=.{{$len2}})/", '...', $url);
252
+ }
253
254
0 commit comments