我正在尝试使用正则表达式来捕获文本行中的IP地址.现在它有点搞砸了.当文本行不包含ip地址时,我的代码返回ip地址,有时返回"Script".我究竟做错了什么?我想返回实际拥有它们的行的ip地址,如果没有则返回任何内容.
文本
2014-06-02 11:53:54.410 -0700 Information 638 NICOLE Client "123456" opening a connection from "123456.local (207.230.229.204)" using "Go 13.0.4 [fmapp]".
2014-06-02 11:54:52.504 -0700 Information 98 NICOLE Client "123456 (123456.local) [207.230.229.204]" closing database "FMServer_Sample" as "Admin".
2014-06-02 12:07:33.433 -0700 Information 638 NICOLE Client "[WebDirect]" opening a connection from "207.230.229.204 (207.230.229.204)" using "Win Chrome 35.0 [fmwebdirect]".
2014-06-02 13:05:00.088 -0700 Information 638 NICOLE Client "Showare Update" opening a connection from "FileMaker Script" using "Server 13.0v1 [fmapp]".
2014-06-02 13:05:22.366 -0700 Information 98 NICOLE Client …Run Code Online (Sandbox Code Playgroud) 我有一个名为$ contents的数组,我循环并写入CSV.我想将列标题写在CSV的顶部,但我只能写入从$ contents数组生成的每一行.我究竟做错了什么?
PHP
$contents = array(date("Y").",".date("m").","."1st half,".$client.",".$resultcasa1.",".$billable_hours);
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=fms_usage.csv');
echo "Year, Month, Period, Client, Minutes Used, Billable Hours,";
$file = fopen("php://output", "w");
foreach($contents as $content){
fputcsv($file,explode(',',$content));
}
fclose($file);
Run Code Online (Sandbox Code Playgroud)
产量
Year Month Period Client Minutes Used Billable Hours 2014 6 1st half roland@fsjinvestor.com 0 0
Year Month Period Client Minutes Used Billable Hours 2014 6 1st half steve@neocodesoftware.com 0 0
Year Month Period Client Minutes Used Billable Hours 2014 6 1st half susanne@casamanager.com 0 0
Year …Run Code Online (Sandbox Code Playgroud) 我正在尝试为多个ajax请求显示两个进度条.每当我的18个ajax请求中的一个完成时,一个进度条达到100%,而当所有18个请求完成时,另一个达到100%.第一个栏很好用,并在我的ajax成功回调中实现.我在触发第二个酒吧时遇到了麻烦,因为我似乎需要第二次成功回调......
这是我的第一个ajax请求的代码.它被调用18次,因为这是我的Config对象中有多少项.
for (var propt in Config) {
var db = '...';
var user = '...';
var pword = '...';
var func = '...';
var dat = {"...": propt };
var url = "https://...";
var callData = jQuery.extend({"Db": db, "User": user, "Password": pword, "Function": func}, dat);
$.ajax({
type: "POST",
url: url,
contentType: "application/json; charset=utf-8",
data: JSON.stringify(callData),
xhr: function() {
var xhr = new window.XMLHttpRequest();
//Download progress
xhr.addEventListener("progress", function(event){
var percentComplete = (event.loaded / event.total)*100;
//Do something with download progress
tableProgressBar(percentComplete); …Run Code Online (Sandbox Code Playgroud) 我试图在某些日期之间从表中选择一些时间项,但我认为我有时间戳/日期时间转换问题.
首先,存储在我的log_tableMySQL表中的记录存储在DATETIME数据类型中,从此,我可以将strtotime()结果用作我的SELECT子句中的日期范围吗?
其次,我可以SELECT从log_time列中日期之间的log_date列中无意中选择我的log_date列吗?截至目前,我被返回一个空数组.
PHP脚本
$date = date("Y-m-d");
$date1 = str_replace('-', '/', $date);
$from_date = date('m-d-Y',strtotime($date1 . "-15 days"));
$date = date("Y-m-d");
$date1 = str_replace('-', '/', $date);
$to_date = date('m-d-Y',strtotime($date1));
$sql2 = "SELECT log_time FROM log_table WHERE log_date >= $from_date AND log_date < $to_date";
$query = $this->db->prepare($sql2);
$query->execute();
$Pro1 = $query->fetchAll();
$Pro1 = array_reverse($Pro1);
print "<pre>";
print_r($from_date);
print "</pre>";
Run Code Online (Sandbox Code Playgroud)