今天午夜我怎样才能在php中获取时间戳.说这是星期一下午5点,我希望周一(今天)午夜(上午12点)的时间戳已经发生.
谢谢
我在胡子循环中遇到问题.基本上,usr能够为产品添加选项.每个选项可以有多个选择.他们也聚在一起选择名称+价格.我收到以下错误:
未捕获的错误:未打开的部分:选择
我的代码:
var choices = new Object();
$("[name='choice_name']").each(function(){
var c_name = $(this).val();
$("[name='choice_price']").each(function(){
var c_price = $(this).val();
choices.choice_name = c_name;
choices.choice_price = c_price;
});
});
console.log(choices);
var templateData = {
name: $("[name='option_name']").val(),
type: $("[name='option_type']").find("option:selected").val(),
choices: choices
};
$.get(default_url+"js_temp/options_widget.html", function(templates){
$('.current_options').append(Mustache.render(templates, templateData));
});
Run Code Online (Sandbox Code Playgroud)
HTML:
<div>
<p class="pull-right"><i class="icon icon-pencil"></i><br /><i class="icon icon-trash"></i></p>
<p><strong>Option Name:</strong> {{option_name}}</p>
<p><strong>Option Type:</strong> {{option_type}}</p>
<hr>
{{choices}}
<div class="row-fluid">
<div class="span7"><p><strong>Choice Name:</strong> {{choice_name}}</p></div>
<div class="span5"><p><strong>Price:</strong> {{choice_price}}</p></div>
</div>
{{/choices}}
</div>
Run Code Online (Sandbox Code Playgroud)
我想我无法实现选择对象的正确格式.我究竟做错了什么?
谢谢.
我想要做的是登录一个网站,然后从表中获取数据,因为他们没有导出功能.到目前为止,我已经设法登录,它显示了用户主页.但是我需要导航到不同的页面或以某种方式抓住该页面,同时仍然使用curl登录.
我的代码到目前为止:
$username="email";
$password="password";
$url="https://jiltapp.com/sessions";
$cookie="cookie.txt";
$url2 = "https://jiltapp.com/shops/shopname/orders";
$postdata = "email=".$username."&password=".$password;
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt ($ch, CURLOPT_REFERER, $url);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$result = curl_exec ($ch);
echo $result;
curl_close($ch);
Run Code Online (Sandbox Code Playgroud)
正如我所提到的,我可以访问主用户页面,但我需要获取$ url2变量的内容,而不是$ url.我怎么能做到这样的事情?
谢谢!
我的目标是获取包含主题标签的字符串并返回所有主题标签.
我的功能:
function get_hashtags($text)
{
preg_match("/(^|\s)#(\w*[a-zA-Z_]+\w*)/", $text, $matches);
return $matches;
}
Run Code Online (Sandbox Code Playgroud)
目前我试试
$text = "yay this is #my comment and it's #awesome and cool";
$tag = get_hashtags($text);
print_r($tag);
Run Code Online (Sandbox Code Playgroud)
我得到:数组([0] => #my [1] => [2] =>我的)
我只想返回一个数组,如
array('tag1', 'tag2', 'tag3');
Run Code Online (Sandbox Code Playgroud)
没有实际的#
我做错了什么,我该如何解决?
谢谢
编辑:有人发布anaswer但它消失了,这正是我想要的,但现在我得到一个错误,代码:
function get_hashtags($text)
{
$matches = array();
preg_match_all("/(^|\s)#(\w*[a-zA-Z_]+\w*)/", $text, $matches);
$result = array();
foreach ($matches as $match) {
$result[] = $match[2];
}
return $result;
}
Run Code Online (Sandbox Code Playgroud)
错误是:未定义的偏移量:2
我该如何解决?
可能重复:
如何在JavaScript中将字符串转换为整数?
我有一个包含产品选项的select元素.我想要实现的是当他们选择一个选项时,页面上的价格会自动调整.我已经想出了如何检索这些值但是当我将它们组合起来时,它只是将两个数字放在一起而不是实际添加它们.
例如,当我有50 + 10时输出60而不输出60输出5010.
我的代码:
$('.product_options').change(function(){
var base_price = $('#base_price').html();
var add_price = $(this).find("option:selected").data('price');
var new_price = base_price+add_price;
console.log(new_price);
$('.current_price').html(base_price+add_price);
Run Code Online (Sandbox Code Playgroud)
});
有没有办法可以将它们转换成整数,以便操作实际通过?
提前致谢!