check substr in str php
<?php
// We can search for the character, ignoring anything before the offset
$newstring = 'abcdef abcdef';
$pos = strpos($newstring, 'a', 1); // $pos = 7, not 0
?>
<?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:
- How to fix undefined index: name in PackageManifest.php line 131 error with Composer
- basic code for file upload in php
- date time pph
- clear the saved cache of my laravel websitefor all the users
- check if array is empty php
- catch http exceptions php
- array unique values php
- d-m-Y php format with minutes
- clear command in laravel
- clear route cache laravel
- enable warnings php
- console log variable php
- 'PHP message: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 282624 bytes)
- Deleting an element from an array in PHP
- date input n php
- echo line php
- check character in string php
- Laravel how to restrict register page
- 'Y-m-d' php
- cache clear in laravel by time
- creating a new project with laravel
- How to pass form variables on all pages laravel helpers
- Date - hours php
- check if a string contains something php