反转可能延长n
时间的二维数组的值.
[1, [2, [3, ... [n, null]]]]
Run Code Online (Sandbox Code Playgroud)
鉴于:
例:
[1, [2, [3, null]]]
将输出 [3, [2, [1, null]]]
[1, [2, [3, [4, null]]]]
会输出 [4, [3, [2, [1, null]]]]
我不确定我是否正确描述它,但我今天遇到了这个练习,并提出了一个相当明显的解决方案.
var ars = [1, [2, [3, null]]], rev = null;
function r(x) {
rev = (rev == null) ? [x[0]] : [x[0], rev];
if( x[1] !== null )
r(x[1]);
}
r(ars);
console.log( rev );
Run Code Online (Sandbox Code Playgroud)
我绝不是一个javascript专家,所以我想知道是否有更好的方法来做到这一点?
我已经获得了一个利用ezpdf类生成PDF文件的项目.问题是,我似乎无法在网上找到任何文件.
通过查看代码本身,我已经找到了我的老板想要实现的大部分更改.我无法弄清楚的是如何更改表头的背景颜色.
有人能指出我正确的方向吗?
使用 wampserver 并收到此错误:
父级:收到关闭信号--正在关闭服务器。
谷歌似乎没有任何有效的解决方案。有任何想法吗?
[Mon Jul 25 19:07:02 2011] [warn] NameVirtualHost *:80 has no VirtualHosts
[Mon Jul 25 19:07:02 2011] [notice] Child 5828: Child process is running
[Mon Jul 25 19:07:02 2011] [notice] Child 5828: Acquired the start mutex.
[Mon Jul 25 19:07:02 2011] [notice] Child 5828: Starting 64 worker threads.
[Mon Jul 25 19:07:02 2011] [notice] Child 5828: Starting thread to listen on port 80.
[Mon Jul 25 19:07:40 2011] [notice] Parent: Received shutdown signal -- Shutting down …
Run Code Online (Sandbox Code Playgroud) 我总是使用这段代码运行一行if语句.
$variable = TRUE; // or anything that evaluates to TRUE
$variable && execute_code();
Run Code Online (Sandbox Code Playgroud)
基本上,如果$variable
为TRUE ,它将运行该函数.
我的问题:这样做的正确用法是什么?
curl_setopt_array( $ch, $curl_opt );
此代码发出通知 Notice: Array to string conversion in ...
这$curl_opt
包含:
array (size=5)
42 => boolean true
19913 => boolean true
10018 => string 'PHP RestClient/0.1.2' (length=20)
10005 =>
array (size=1)
0 => string 'user:password' (length=13)
10002 => string 'http://longurl.com/' (length=389)
Run Code Online (Sandbox Code Playgroud)
is_array($curl_opt)
返回true
,所以我真的不知道是什么导致通知.
我想我只是错过了一些非常简单的东西,但我不能,因为我的生活,想出这个.
这只是一个通知,并没有打破任何东西,但它只是让我烦恼,我不知道是什么导致它.
我有一个单词列表,我想在PHP中使用这个单词列表解读单词.
在我看来,PHP没有内置函数来做到这一点.那么有人可以建议一个好的算法来做到这一点,或者至少指出我正确的方向?
编辑:编辑添加示例
所以基本上,我所说的是我有一个单词列表:
apple
banana
orange
Run Code Online (Sandbox Code Playgroud)
然后,我收到了一堆乱七八糟的信件.
pplea
nanaba
eroang
Run Code Online (Sandbox Code Playgroud) 我知道标题有点混乱,但这是我所能做的最好的事情。= P
希望有人能够提供帮助。
我正在使用CodeIgniter,并且在具有多个参数的基类中有一个方法:
class MY_Base extends CI_Model {
function some_function($param1, $param2 ... $param8) {
// do stuff
}
}
Run Code Online (Sandbox Code Playgroud)
我想做的基本上是在一个子班上:
class Child extends MY_Base {
function some_function($param1, $param2 ... $param8) {
parent::some_function($param1, $param2 ... $param8);
// call a methods found in this class only
$this->some_method();
}
function some_method() {
// do more stuff
}
}
Run Code Online (Sandbox Code Playgroud)
我无法触及基类,因此必须从基类进行扩展。问题是,参数太多。而且这也发生在不同的方法中,有时我会忘记使代码失败的方法。
所以我想知道,是否有办法这样写:
function some_function(__PARAMETERS__) {
parent::some_function(__PARAMETERS__)
}
Run Code Online (Sandbox Code Playgroud)
我似乎隐约记得这是可能的,但我在Google中找不到。可能是因为我搜索了错误的关键字。
任何帮助,将不胜感激。
编辑:然后,当然,我func_get_args()
在发布此问题后找到了。这似乎可以满足我的要求,但是我会把这个问题留给大家更好的主意。
苦苦挣扎这一点.
尝试添加PHP构建系统这就是我所拥有的:
{
"cmd" : ["php", "$file"],
"file_regex": "php$",
"selector" : "source.php"
}
Run Code Online (Sandbox Code Playgroud)
现在,构建一个名为test.php
contains 的文件会<?php echo "Hello, World!"; ?>
产生以下错误:
[WinError 2] The system cannot find the file specified
[cmd: ['php', 'D:\\www\\sandbox\\php\\test.php']]
[dir: D:\www\sandbox\php]
Run Code Online (Sandbox Code Playgroud)
PHP肯定在我的PATH
运行php test.php
命令行工作.
谁能在这里解决一些问题?
所以我一直在谷歌搜索一下,似乎无法找到答案.
据我所知,这段代码:$this->upload->initialize()
使用upload.php
配置文件初始化CI文件上传类.我想要做的是使用不同的文件.
我试过了$this->upload->initialize('upload_other')
,但这似乎不起作用.我知道你可以$config
在控制器中设置一个数组,但我试图避免这种情况.
这可能吗?我是以错误的方式接近这个吗?
嗨所以我有这个jQuery/JS脚本.这基本上采用编码的URL字符串并解析它并将变量值保存到变量中.
基本上是PHP的$ _GET.
function getUrlVars()
{
var map = {};
var parts = window.location.search.replace(/[?&]+([^=&]+)(=[^&]*)?/gi,
function(m,key,value)
{ map[key] = (value === undefined) ? true : value.substring(1); });
return map;
}
Run Code Online (Sandbox Code Playgroud)
基本上这个脚本做我想要的.从此URL字符串:
/autopop.html?Email=test%40test.com&LastName=Test+last&&FirstName=+Test+First
Run Code Online (Sandbox Code Playgroud)
我得到了价值观:
Email = test%40test.com
LastName = Test+last
FirstName = +Test+First
Run Code Online (Sandbox Code Playgroud)
我想要做的是使用此信息在同一页面上自动填充表单.(我知道你在想什么服务器端脚本会是一个更好的解决方案,但老板说我们无法访问它,相信我,我已经尝试过了)
长话短说,这是我的其余代码:
var keys = getUrlVars();
$(document).ready(function(){
var fname = keys['FirstName'].replace(/\+/g , " ").trim();
var lname = keys['LastName'].replace(/\+/g , " ").trim();
var email = decodeURIComponent(keys['Contact0Email'].replace(/\+/g , " ")).trim();
$("#Email").val(email);
$("#FirstName").val(fname);
$("#LastName").val(lname);
});
Run Code Online (Sandbox Code Playgroud)
这段代码完成了工作.除了一个浏览器外.IE浏览器.
IE不支持decodeURIComponent
或所以我读过.无论如何,我尝试使用其他功能,decodeURI
并且escape …
基本上,我只想显示范围中选择的任何内容并隐藏其余部分.
我做的方式似乎是这样......我不知道.乏味.
我希望得到一些让它变得更好的想法.正确方向上的一点也将非常受欢迎.
谢谢.
php ×8
javascript ×3
codeigniter ×2
html ×2
jquery ×2
algorithm ×1
apache ×1
arrays ×1
config ×1
curl ×1
ezpdf ×1
ezpublish ×1
sublimetext ×1
sublimetext3 ×1
terminology ×1
wampserver ×1