小编DCH*_*CHP的帖子

数组搜索不起作用

我有下面的代码.

$coauthors = get_post_meta( $post_id, "coAuthors" );

print_r($coauthors);
Run Code Online (Sandbox Code Playgroud)

print_r的确定结果是

Array ( [0] => 78 ) Array ( [0] => 78 )
Run Code Online (Sandbox Code Playgroud)

现在我的用户ID是78所以它应该使用以下代码返回true但它不是.

$key = array_search( 78, $coauthors );

     if($key) { 

     return true;

     }else{

     echo "no"; 

     }
Run Code Online (Sandbox Code Playgroud)

为什么我总是得不到我错在哪里最好的办法是什么?

谢谢

我在这里仍然遇到问题是我的功能.

   add_action('is_true','isdAuthorTrue');

    function isdAuthorTrue( $post_id ) { 

        $current_user = wp_get_current_user();
    if ( !($current_user instanceof WP_User) )
    return;

        $current_user = wp_get_current_user();

         $coauthors = get_post_meta( $post_id, "coAuthors" );

         $key = array_search( $current_user->ID, $coauthors );
         $key = 0;
         if($key !== false) {

           return true;

         } …
Run Code Online (Sandbox Code Playgroud)

php arrays wordpress

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

在mac上通过终端安装GPG工具

我想在mac mini上安装gpg工具我有ssh访问权限,所以我可以安装s3cmd.

我知道你可以在这里使用安装程序dmg http://www.gpgtools.org/installer/index.html

但由于我只有ssh访问,我需要通过终端安装这个,并且无法找到在哪里这样做,如果我点击源它带我到这个页面https://github.com/GPGTools/GPGTools这对我没有帮助.

有人能指出我正确的方向.

terminal gnupg

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

ruby on rails错误rake db:create

我一直在rails上使用ruby没问题,现在突然每次我运行rake db:create我得到以下错误:

C:\>cd xampp

C:\xampp>cd htdocs

C:\xampp\htdocs>cd what

C:\xampp\htdocs\what>rake db:create
rake aborted!
undefined method `task' for #<What::Application:0x20eb1e0>

(See full trace by running task with --trace)

C:\xampp\htdocs\what>
Run Code Online (Sandbox Code Playgroud)

有什么帮助吗???

这是我的所有cmd

   C:\xampp\htdocs\comeon>rake db:create --trace
rake aborted!
undefined method `task' for #<Comeon::Application:0x211fb30>
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:215:
in `initialize_tasks'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:139:
in `load_tasks'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:77:i
n `method_missing'
C:/xampp/htdocs/comeon/Rakefile:7:in `<top (required)>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `lo
ad'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `lo
ad_rakefile'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:495:in `r
aw_load_rakefile'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:78:in `bl
ock in load_rakefile'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:129:in `s
tandard_exception_handling'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:77:in `lo
ad_rakefile'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:61:in `bl
ock in run'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:129:in `s
tandard_exception_handling'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:59:in `ru …
Run Code Online (Sandbox Code Playgroud)

ruby rake ruby-on-rails

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

怪异的<! - php标签形成数据库

有没有人有这个问题,当我从数据库中提取数据时,它看起来像下面,它在实际的数据库表中看起来很好.

我正在使用wordpress.任何建议都让我头疼.

这些是标签

<pre><!--? if (function_exists('externalGetSociofluidButtonsForCurrentUrl'))
                {echo externalGetSociofluidButtonsForCurrentUrl();} ?-->
<!--?php DisplayVotes(get_the_ID()); ?-->
<!--?php MostVotedAllTime(); ?--></pre>
Run Code Online (Sandbox Code Playgroud)

php database wordpress formatting

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

Colourbox和timthumb.php

我遇到了timthumb.php和colourbox灯箱的问题,timthumb在其他一切方面工作得很好但是当我尝试加载更大的图像时,我得到以下内容

在此输入图像描述

图像只显示代码真的需要帮助???

这是我的代码.

if ($handle = opendir('./users/2/images')) {
    while (false !== ($entry = readdir($handle))) {


        if ($entry != "." && $entry != "..") {

            if(preg_match("/\.(png|gif|jpg|jpeg|JPG)$/i", $entry)) {

            $file = site_url() . "/users/2/images/$entry";

            $removeLink = "users/2/images/$entry";

          echo '<li><a class="group1" href="'.get_bloginfo('template_url').'/timthumb.php?src='.$file.'&h=500&q=80&webshot=1"><img src="'.get_bloginfo('template_url').'/timthumb.php?src='.$file.'&h=80&zc=1"  onload="this.style.visibility=\'visible\'" /></a><a href="'.$file.'" rel="nofollow">Download</a><a class="imageSort" href="" id="'.$removeLink.'" title="images">drag me</a><a href="'.$file.'" rel="nofollow">View Raw</a></li>';      

            } 
        } 
    }
    closedir($handle);
Run Code Online (Sandbox Code Playgroud)

有谁有类似的问题???

碰到任何人得到和建议与这???

<?php
/**
 * TimThumb by Ben Gillbanks and Mark Maunder
 * Based on work done by Tim McDaniels and Darren Hoyt
 * …
Run Code Online (Sandbox Code Playgroud)

php lightbox

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