Click here to Skip to main content
15,888,579 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
QuestionCovert singleton class for php 4.4.4 to php 5.2 [modified] Pin
malrajphp1-Jul-09 22:11
malrajphp1-Jul-09 22:11 
AnswerRe: Covert singleton class for php 4.4.4 to php 5.2 Pin
Marc Firth2-Jul-09 4:17
Marc Firth2-Jul-09 4:17 
QuestionNew to PHP Pin
NimishaLad30-Jun-09 8:44
NimishaLad30-Jun-09 8:44 
AnswerRe: New to PHP Pin
EliottA30-Jun-09 9:20
EliottA30-Jun-09 9:20 
AnswerRe: New to PHP [modified] Pin
Marc Firth30-Jun-09 23:40
Marc Firth30-Jun-09 23:40 
AnswerRe: New to PHP Pin
malrajphp2-Jul-09 4:02
malrajphp2-Jul-09 4:02 
AnswerRe: New to PHP Pin
SandipG 3-Jul-09 2:39
SandipG 3-Jul-09 2:39 
QuestionPHP help - unsure how to approach the unique needs for a random order script for a project Pin
Chris Averill30-Jun-09 3:22
Chris Averill30-Jun-09 3:22 
Hi all,

I'm looking for some direction in how to approach this problem.

$arr = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20);

I need to create a second array using the values in the first array in a random order, without repeating or omitting any of the values, except one of them.

I'm having such a hard time with this next part, and I even struggle to explain it. So please clarify as needed.

I need to fill the second array with a random combination of the first array, with one value repeated. But the value that is repeated has to be randomly selected from the first five positions of the new array, and it has to be placed randomly into one of the last five positions of the new array.

so assuming that the first five values of the randomly generated array are:
3, 7, 8, 19, 14

I would need to continue randomly filling the 2nd array with values from the first array ($arr, above) until I fill position 15 (the 16th value). Then positions 16-20 (17th through 21st values) need to have the 4 remaining numbers and one of the numbers from the first five spots (3, 7, 8, 19, or 14 in this example).

So that the final array would look something like this

$arr2 = array(
0 => 3,
1 => 7,
2 => 8,
3 => 19,
*4 => 14,

5 => 1, 6=>2, 7=>4, 8=>20, 9=>18, 10=>16, 11=>15, 12=>12, 13=>11, 14=>6, 15=>10,

16 => 17,
17 => 5,
*18 => 14,
19 => 9,
20 => 13);

I've indicated the repeated number with an asterisk and have used position => value nomenclature hoping for clarity.

In this case the value in position 4 is repeated in position 18.

I need this part randomly figured out during each iteration in addition to randomly filling all the original values contained in the first array. So the example above would be only one possible outcome.

Thanks in advance for any guidance you can provide. Please let me know if what I'm asking is not clear and I will try to clarify as needed.

Cheers,

Chris
AnswerRe: PHP help - unsure how to approach the unique needs for a random order script for a project Pin
Luc Pattyn30-Jun-09 4:12
sitebuilderLuc Pattyn30-Jun-09 4:12 
Questioncovert excel to pdf Pin
jhyn28-Jun-09 20:00
jhyn28-Jun-09 20:00 
AnswerRe: covert excel to pdf Pin
Marc Firth28-Jun-09 22:24
Marc Firth28-Jun-09 22:24 
AnswerRe: covert excel to pdf Pin
jhyn29-Jun-09 14:02
jhyn29-Jun-09 14:02 
GeneralRe: covert excel to pdf Pin
EliottA29-Jun-09 15:52
EliottA29-Jun-09 15:52 
QuestionHow to save/serialize stdClass (result of SOAP function) to XML? Pin
Michal Drozd28-Jun-09 8:21
Michal Drozd28-Jun-09 8:21 
QuestionCapturing the path to a page link activation Pin
Member 373991027-Jun-09 15:50
Member 373991027-Jun-09 15:50 
AnswerRe: Capturing the path to a page link activation Pin
Marc Firth28-Jun-09 22:22
Marc Firth28-Jun-09 22:22 
GeneralRe: Capturing the path to a page link activation Pin
Member 373991029-Jun-09 14:22
Member 373991029-Jun-09 14:22 
QuestionNeed help to create thumbanil in linux Pin
malrajphp27-Jun-09 3:27
malrajphp27-Jun-09 3:27 
AnswerRe: Need help to create thumbanil in linux Pin
Marc Firth28-Jun-09 22:17
Marc Firth28-Jun-09 22:17 
GeneralRe: Success in create thumbanil in linux [modified] Pin
malrajphp1-Jul-09 21:58
malrajphp1-Jul-09 21:58 
QuestionRemember to create membership in http://www.codeproject.com/ Pin
malrajphp27-Jun-09 3:21
malrajphp27-Jun-09 3:21 
AnswerRe: Remember to create membership in http://www.codeproject.com/ Pin
fly90427-Jun-09 3:34
fly90427-Jun-09 3:34 
AnswerRe: Remember to create membership in http://www.codeproject.com/ Pin
Marc Firth28-Jun-09 22:16
Marc Firth28-Jun-09 22:16 
AnswerRe: Remember to create membership in http://www.codeproject.com/ Pin
Sk9330-Jun-09 5:01
Sk9330-Jun-09 5:01 
QuestionPHP Header() error Pin
Samiullah26-Jun-09 2:56
Samiullah26-Jun-09 2:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.