find char in string php
strpos ( string $haystack , mixed $needle [, int $offset = 0 ] ) : int<?php
function g($string,$start,$end){
preg_match_all('/' . preg_quote($start, '/') . '(.*?)'. preg_quote($end, '/').'/i', $string, $m);
$out = array();
foreach($m[1] as $key => $value){
$type = explode('::',$value);
if(sizeof($type)>1){
if(!is_array($out[$type[0]]))
$out[$type[0]] = array();
$out[$type[0]][] = $type[1];
} else {
$out[] = $value;
}
}
return $out;
}
print_r(g('Sample text, [/text to extract/] Rest of sample text [/WEB::http://google.com/] bla bla bla. ','[/','/]'));
?>
results:
Array
(
[0] => text to extract
[WEB] => Array
(
[0] => http://google.com
)
)
Can be helpfull to custom parsing :)
Also in PHP:
- char to uppercase php
- check php for errors
- file_put_contents true php
- all my php codes redirects to one site
- detect find char in string php position
- date method php
- claer database connection cache laravel
- find substring in string php
- am pm in php
- configure laravel on windows
- Allowed memory size o
- .$_REQUEST['number2'] case php switch
- date function plus 1 day php
- clear cache artisan
- file in array
- MySQL integer field is returned as string in PHP
- check if keys exists array php
- Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar://C:/Users/Public/composer.phar/src/Composer/DependencyResolver/Solver.php on line 223
- add one day to given date in php
- NAME OF YOUR FORM in contact form 7
- echo today date in php
- codeigniter
- converting string to uppper case in PHP
- PHP date('H')