check a string for a string php
if (strpos($string, 'substring') !== false) {
// do stuff
}<?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:
- Laravel store multiple files
- date + 1 php
- .length php
- create a directory using php
- file not reading in php fgets
- check if array has value php
- clear the cache
- create laravel initialize cache
- Tests\Feature\BlogTest > user can delete post 162 Illuminate\Encryption\MissingAppKeyException No application encryption key has been specified.
- change header location in php
- DateTime::diff()
- currency convertor in php
- check if keys exists array php
- check if key array exists php
- PHP message: PHP Fatal error: Uncaught TypeError: Argument 2 passed to Magento\Eav\Model\Attribute\Data\Text::validateLength() must be of the type string, null given
- character count in php
- create a laravel app
- failed to open stream: no such file or directory php
- error reporting panvil.works
- all php exception
- check if key exist in php
- echo all error
- enable all php errors
- clear cache artisan laravel