find string in the 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:
- buscar palabra en un string php
- codeigniter where_not_in
- date to format php
- console log variable php
- addphp calculate next letter
- Auth log out laravel
- 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table `shoppingcart` add primary key `shoppingcart_identifier_instance_primary`(`identifier`, `instance`))
- days into date in php
- array_push php
- check all page names with tempalte
- enqueue wordpress
- clear cache after delete post lara el
- chech array key exist
- When you click on the search button, it is moved to the page laravel
- Web servers supported by php
- convert date in php
- check if specific index of array exist php
- date time format in php
- artisan migrate table
- exist in string php
- enable error reporting in php
- append rand php to string
- codeigniter base_url
- create new laravel project terminal