[英]How can get data between two dates?
270|in-profit.biz|test|3|2012-10-27 00:00:00||just for test 270|in-profit.biz|test|3|2012-10-27 00:00:00||仅供测试
379|yourhourly.com|Yourhourly.com|3|2015-03-11 00:00:00||101% After
1 Hour<br> How do i get value like as:
$value1 = 270
$value2 = in-profit.biz
$value3 = test
$value4 = 3
of each line每行
You can use preg_match()
for that您可以为此使用preg_match()
$string = "270|in-profit.biz|test|3|2012-10-27 00:00:00||just for test";
preg_match_all('/(.*?)\|(.*?)\|(.*?)\|(.*?)\|/i', $string, $matches, PREG_PATTERN_ORDER);
$value1 = $matches[1][0];
$value2 = $matches[2][0];
$value3 = $matches[3][0];
$value4 = $matches[4][0];
echo $value1;
echo $value2;
echo $value3;
echo $value4;
Output: Output:
270
in-profit.biz
test
3
Alternatively you can use explode()
或者你可以使用explode()
$string = "270|in-profit.biz|test|3|2012-10-27 00:00:00||just for test";
$matches = explode('|', $string );
$value1 = $matches[0];
$value2 = $matches[1];
$value3 = $matches[2];
$value4 = $matches[3];
echo $value1;
echo $value2;
echo $value3;
echo $value4;
Output: Output:
270
in-profit.biz
test
3
If you have a string like如果你有一个像这样的字符串
$str = 'aaa|bbb|ccc|ddd|eeeee|fffffff'
or any set of values separated by |
或由|
分隔的任何一组值, you can split it using split()
like such ,您可以像这样使用split()
拆分它
$results = split('\|', $str);
This will give you an array of strings that you will be able to work with这将为您提供一组您可以使用的字符串
$results[0] = 'aaa'
$results[1] = 'bbb'
...
$results[5] = 'fffffff'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.