小编Jud*_*yon的帖子

合并两个多维关联数组

我正在追逐我的尾巴试图将两个不同查询的结果组合在一个模板中输出.

我正在尝试合并model_data和entry_data中的相应子数组以获取desired_result.然后,我将遍历desired_result并将值打印到模板中.

非常感谢任何帮助.

model_data

array(2) {
  [0]=>
  array(2) {
    ["entry_id"]=> string(3) "192"
    ["field_id_49"]=> string(10) "Model Name"
  }
  [1]=>
  array(2) {
    ["entry_id"]=> string(3) "193"
    ["field_id_49"]=> string(5) "MN123"
  }
}
Run Code Online (Sandbox Code Playgroud)

entry_data

array(2) {
  [0]=>
  array(2) {
    ["uri"]=> string(24) "/products/product-title/"
    ["title"]=> string(13) "Product Title"
  }
  [1]=>
  array(2) {
    ["uri"]=> string(22) "/products/lorem-ipsum/"
    ["title"]=> string(11) "Lorem Ipsum"
  }
}
Run Code Online (Sandbox Code Playgroud)

desired_result

array(2) {
  [0]=>
  array(4) {
    ["entry_id"]=> string(3) "192"
    ["field_id_49"]=> string(10) "Model Name"       
    ["uri"]=> string(24) "/products/product-title/"
    ["title"]=> string(13) "Product Title"      
  }
  [1]=>
  array(4) {
    ["entry_id"]=> string(3) …
Run Code Online (Sandbox Code Playgroud)

php arrays multidimensional-array array-merge

4
推荐指数
1
解决办法
3378
查看次数

让Fabric Python库工作

我通过Pip安装了Fabric,它是通过Homebrew(OS X 10.6.6)安装的.Fabric库是pip应该的地方,但是我无法获得基本的fabfile.

我尝试过这里找到的简单的hello world示例:http://docs.fabfile.org/en/1.0.1/tutorial.html

当我尝试使用fab hello时,Bash给出了以下错误: -bash:fab:command not found

路径:

  • Python 2.7.1:/ usr/local/bin/python
  • pip库:/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages

我可能忽视了一些愚蠢的事情.谢谢您的帮助.

python homebrew pip fabric

1
推荐指数
1
解决办法
7432
查看次数