php: Extract URLs from String
2019-08-07
Q: How to extract URLs from a string with php ?
A: use the php function preg_match_all
to acvhieve this.
example
// example string with URLs
$sContent = 'https://blog.ueffing.net, FOO BAR BLA BLA https://www.ueffing.net/, BLA BLA https://github.com/gueff';
$sPattern = "/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i";
preg_match_all(
$sPattern,
$sContent, […]
php: find a value in multidimensional array
2019-08-03
Q: given a multidimensional array. how can i find a value in it ?
A: use the php function array_search
in conjunction with array_column
to solve this.
usage example
$aData = [
'aKeyValue' => [
0 => [
'sKey' => 'sOldname',
'sValue' => '/media/foo.txt',
],
1 => [
'sKey' => 'sNewname',
[…]