使用'array_rand'时出现问题(显示数字而不是数组项) [英] Trouble when using 'array_rand' (displaying numbers instead of array items)

查看:364
本文介绍了使用'array_rand'时出现问题(显示数字而不是数组项)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


当我在网页上回复我的文章时,我需要为它们设置随机样式,为此我需要将随机类添加到我的< div>


这是我到目前为止所得到的

Hello,

When I echo my articles on a webpage I need to set random style to them, to do so I need to add random class to my <div>

This is what I''ve got so far

展开 | 选择 | 换行 | 行号

推荐答案


但是它给了一个0或有时数组的类,而不是给它一个随机类的story_style1。
but instead of giving it a random class of story_style1 it gives it a class of 0 or sometimes array.



但这就是array_rand()应返回的内容。

来自手册的

but that is what array_rand() is supposed to return.

from the manual:

返回值

如果只选择一个条目,array_rand()将返回随机条目的键。否则,它返回随机条目的键数组。这样做是为了您可以选择随机键以及数组中的值。
Return Values
If you are picking only one entry, array_rand() returns the key for a random entry. Otherwise, it returns an array of keys for the random entries. This is done so that you can pick random keys as well as values out of the array.


thnx,但有没有办法随机选择那些story_style1等。从阵列?没有别的只是我想要使用的那些定义的类?


thnx
Hi, thnx, but is there a way to randomly select those "story_style1 etc." from array? nothing else just those defined classes I want to use?

thnx


怎么样

这篇关于使用'array_rand'时出现问题(显示数字而不是数组项)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆