我有一个关于选择JSON对象的部分并检查它们是否具有值的问题.
我在PHP中从API加载JSON:
$json_url ='http://api.url.com/api/gateway/call/1.4/getApp?appid=2631';
$ch = curl_init($json_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$str = curl_exec($ch);
curl_close($ch);
$data = json_decode($str);
Run Code Online (Sandbox Code Playgroud)
输出数据是:
object(stdClass)[1]
public 'app' =>
array
0 =>
object(stdClass)[2]
public 'id' => string '2631' (length=4)
public 'apptypeid' => string '3' (length=1)
public 'organizerid' => string '913' (length=3)
public 'accountId' => string '687' (length=3)
public 'name' => string 'Meet in Liege' (length=13)
public 'info' => string '' (length=0)
public 'submit_description' => string '' (length=0)
public 'category' => string '' (length=0)
public 'app_icon' => string …Run Code Online (Sandbox Code Playgroud) 我正在为我的问题寻找解决方案.
我有一段带有Twitter推文的文字.现在我想将所有'@'改为颜色.
这就是我在文本中寻找'@'的方法:
if (status.indexOf("@") >= 0)
{
}
Run Code Online (Sandbox Code Playgroud)
但是现在我怎样才能改变@的颜色?(添加范围和类或其他东西......)
状态是一个变量,其内容为ex.像这样:
Dita Von Teese draagt geprinte 3D-jurk <a target="_blank" href="http://t.co/s2y6b21S0I">http://t.co/s2y6b21S0I</a> via @<a target="_blank" href="http://twitter.com/Knackweekend">Knackweekend</a>
Run Code Online (Sandbox Code Playgroud) 我有一个带有 ajax 调用的数据表。我像这样形成表格:
var _initTable = function() {
$('#datatables tr').not(':first').on('click', function() {
var dateandtime = $(this).find(':nth-child(3)').text();
window.location.href = '/results/detail/dateandtime/' + dateandtime;
});
};
$('#datatables').dataTable({
bProcessing : true,
sProcessing : true,
bServerSide : true,
sAjaxSource : '/results/load-results',
fnServerParams: function ( aoData ) {
aoData.push( {"name": "quizid", "value": quizid },{ "name": "questionid", "value": questionid } );
},
aoColumnDefs : [{'bSortable' : false, 'aTargets' : ['no-sort']}], // make the actions column unsortable
sPaginationType : 'full_numbers',
fnDrawCallback : function(oSettings) {
_initTable();
}
});
Run Code Online (Sandbox Code Playgroud)
如您所见,我向我的 …
我想创建一个表单,只开始从数据库中选择的值的选择列表.
这是实体区域,我想用区域填写下拉列表.
<?php
namespace Reuzze\ReuzzeBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Regions
*
* @ORM\Table(name="regions")
* @ORM\Entity
*/
class Regions
{
/**
* @var integer
*
* @ORM\Column(name="region_id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $regionId;
/**
* @var string
*
* @ORM\Column(name="region_name", type="string", length=45, nullable=false)
*/
protected $regionName;
/**
* Get regionId
*
* @return integer
*/
public function getRegionId()
{
return $this->regionId;
}
/**
* Set regionName
*
* @param string $regionName
* @return Regions
*/
public function …Run Code Online (Sandbox Code Playgroud) 我想用jquery autocomplete进行ajax调用,如下所示:
$("#register_player_team").autocomplete({
source: function( request, response ) {
$.ajax({
url: "{{path('volley_scout_getteams_data')}}",
dataType: "jsonp",
success: function( data ) {
console.log(data);
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr.status);
console.log(thrownError);
}
});
}
});
Run Code Online (Sandbox Code Playgroud)
在我的routing.yml中,我定义了以下路由:
volley_scout_getteams_data:
pattern: /team/getteams
defaults: { _controller: VolleyScoutBundle:Team:getteams }
Run Code Online (Sandbox Code Playgroud)
在我的TeamController中,我有一个名为getteamsAction()的动作:
public function getteamsAction()
{
$entityManager = $this->getDoctrine()->getManager();
// Get teams from database
$teams = $entityManager->getRepository('VolleyScoutBundle:Teams')->findAll();
foreach($teams as $team){
var_dump($team);
}
die();
}
Run Code Online (Sandbox Code Playgroud)
(dump和die()仅用于测试,我想检查他是否可以找到链接).但是当我想进行ajax调用时,我总是会收到以下错误:
http://localhost:8080/volleyscout/web/app_dev.php/user/%7B%7Bpath('volley_s…)%7D%7D?callback=jQuery110207641139030456543_1389372448462&_=1389372448463 404 (Not Found)
Run Code Online (Sandbox Code Playgroud)
由于某种原因,他无法找到行动......有人知道我做错了什么吗?当我尝试这样的链接时:web/app_dev.php/team/getteams我得到了团队的转储..
更新: 我的javascript链接在基本视图(twig)中定义,如下所示:
{% block javascripts %}
{% …Run Code Online (Sandbox Code Playgroud) 我想在两个日期之间选择这样的:
SELECT p.Code, p.Name, sum(h.PA = 1) AS PA, sum(h.PB = 1) AS PB,
sum(h.PG = 1) AS PG, sum(h.GoedkeuringDoorNew = 'GF') AS GF,
sum(h.GoedkeuringDoorNew = 'SB') AS SB, sum(h.GoedkeuringDoorNew = 'VIA') AS VIA,
sum(h.Blanco) AS Blanco
FROM psthostess p
LEFT JOIN `psttodo-uit` h
ON h.`Hostess Code` = p.Code
AND DATE(h.`afgewerkt tablet datum`) BETWEEN CURDATE()
AND (CURDATE() - INTERVAL 1 DAY)
WHERE p.Indienst = 1 GROUP BY p.Code, p.Name
Run Code Online (Sandbox Code Playgroud)
但我没有得到任何结果.
我想要今天和昨天的结果.但是当我这样做的时候
SELECT *
FROM `psttodo-uit` p
WHERE DATE(p.`afgewerkt tablet datum`) …Run Code Online (Sandbox Code Playgroud) 这就是我现在所做的:
if (strpos($routeName,'/nl/') !== false) {
$routeName = preg_replace('/nl/', $lang , $routeName, 1 );
}
Run Code Online (Sandbox Code Playgroud)
我替换了nlfor for ex.de.但现在我想取代second occurrence.最简单的方法是什么?
我正在做一个流浪汉机器(Homestead).在我的Homestead.yml我有:
sites:
- map: myproject.local
to: /home/vagrant/projects/myproject/web
type: symfony
Run Code Online (Sandbox Code Playgroud)
我在PHP 7.1.2上使用Symfony 3.3版.
问题是当我尝试执行命令时,php bin/console cache:clear我收到以下错误:
[Symfony\Component\Filesystem\Exception\IOException]无法删除目录"/ home/vagrant/projects/vkfilestore-code/var/cache/de~/pools":.
在我的AppKernel.php中我有:
public function getCacheDir()
{
return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
}
Run Code Online (Sandbox Code Playgroud)
当我转储$this->getEnvironment()它说dev.
这可能是什么问题?
现在我有以下查询:
$passed = Deployment::where('created_at', '<=', Carbon::now()->subDays(15)->toDateTimeString())->get();
Run Code Online (Sandbox Code Playgroud)
但现在我想在这样的地方添加第二个:WHERE closed_domain == 0.
但是如何将其添加到当前查询中?我已经尝试过::而且没有成功......
我正在尝试更改我的服务器(LEMP Stack)上的upload_max_filesize的 php 配置。
在 phpinfo 中我可以看到:
Loaded Configuration File: /etc/php/7.2/fpm/php.ini
Run Code Online (Sandbox Code Playgroud)
我已在此文件中将 upload_max_filesize 更改为 256M。
然后我通过运行以下命令重新启动:systemctl restart nginx。
问题是当我检查我的 phpinfo 时它没有改变......
php ×8
javascript ×3
jquery ×3
symfony ×3
ajax ×2
mysql ×2
arrays ×1
caching ×1
css ×1
curl ×1
datatables ×1
date ×1
doctrine ×1
environment ×1
homestead ×1
html ×1
ini ×1
json ×1
laravel ×1
laravel-5 ×1
laravel-5.1 ×1
preg-replace ×1
replace ×1
select ×1
sql ×1