473,406 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

array_rand anomaly: "/" removed from values.

I took me some considerable time to work out what was going wrong.

I had been trying to use the array_rand function to gather a random selection of images to display, each of which to be referenced with a number string prefixed with a "/" slash, for example "/106".

The trouble then turned out to be that the array_rand function, for whatever reason best known to itself, returns the requisite assorttment of selected values, but with the slashes all stripped from the returned result, with the "/106" for instance returned as a mere "106".

This was easy enought to fix, as soon as the unexpected result was detected as the reason for the failure to achieve the expected result. It works fine with the array_keys function used to extract an array of keys to use as a proxy, in order then to extract from the keys array to reference in turn the original array.

I am raising the subject here to warn of the unfortunate possibility, and to wonder if anybody has any insight to offer as to why the slashes would be stripped off to begin with, and if therfore this might happen with other cases. I had rather hoped that including the slashes would tend to make sure that the array values would not be treated as scalar values, but perhaps the effect is rarther the opposite, that they persuade the array_rand function to treat them in this particular fashion.

I had thought that perhaps the function was trying to divide by the value, except that 0 divided by 106 should be 0, not 106.

-- RH.
Nov 4 '06 #1
0 999

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: Jordan Rastrick | last post by:
First, a disclaimer. I am a second year Maths and Computer Science undergraduate, and this is my first time ever on Usenet (I guess I'm part of the http generation). On top of that, I have been...
27
by: Abdullah Kauchali | last post by:
Hi folks, Can one rely on the order of keys inserted into an associative Javascript array? For example: var o = new Object(); o = "Adam"; o = "Eve";
3
by: Pavils Jurjans | last post by:
Hello, I have bumped upon this problem: I do some client-side form processing with JavaScript, and for this I loop over all the forms in the document. In order to identify them, I read their...
0
by: Alvey Sidecast | last post by:
Well it is to me anyway. ------------------------------ Access Version = 2002 OS = XP Pro User = Ordinary to bumbling ------------------------------ I was writing some sql yesterday which...
16
by: PeteCresswell | last post by:
I was happily coding along, putting some calculation results (rolling annualized rates of return - too compute-intensive to calculate on-the-fly - had tb staged beforehand via a batch job) into...
37
by: mdh | last post by:
In one of the answers to a K&R exercise, the first couple of lines are: enum loop { NO, YES}; enum loop okloop=YES; I get the first line, but not the second. Sorry about the LOL question. ...
37
by: jht5945 | last post by:
For example I wrote a function: function Func() { // do something } we can call it like: var obj = new Func(); // call it as a constructor or var result = Func(); // call it as...
1
by: mai | last post by:
Hi everyone, i'm trying to exhibit FIFO anomaly(page replacement algorithm),, I searched over 2000 random strings but i couldnt find any anomaly,, am i I doing it right?,, Please help,,,The...
2
Lazandra
by: Lazandra | last post by:
Hi guys I'm trying to display one database entry randomly. So i have used array_rand(). However i have completely confused myself, and close to hitting my monitor with a tree branch. This is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.