Hi
I have a php string like this:
$string = "one two three four five"
I have to sorting the values randomly every time the page are loaded.
So, for example:
first time
"one two three four five"
second time
"three five one four two"
third time
"five four two one three"
....
The number are a images in a folder and I have to sort these images in
a random sequence.
Thanks for suggestions. 7 3731
On Thu, 06 Sep 2007 15:39:06 +0200, pt36 <ke*********@gm ail.comwrote:
Hi
I have a php string like this:
$string = "one two three four five"
I have to sorting the values randomly every time the page are loaded.
So, for example:
first time
"one two three four five"
second time
"three five one four two"
third time
"five four two one three"
...
The number are a images in a folder and I have to sort these images in
a random sequence.
Thanks for suggestions.
$string = "one two three four five";
$array = explode(' ', $string);
shuffle($array) ;
$string = implode(' ',$string);
--
Rik Wasmus
On Thu, 06 Sep 2007 15:47:51 +0200, Rik Wasmus
<lu************ @hotmail.comwro te:
On Thu, 06 Sep 2007 15:39:06 +0200, pt36 <ke*********@gm ail.comwrote:
>Hi I have a php string like this: $string = "one two three four five" I have to sorting the values randomly every time the page are loaded. So, for example: first time "one two three four five" second time "three five one four two" third time "five four two one three" ... The number are a images in a folder and I have to sort these images in a random sequence. Thanks for suggestions.
$string = "one two three four five";
$array = explode(' ', $string);
shuffle($array) ;
$string = implode(' ',$string);
....ofcourse:
$string = implode(' ',$array);
--
Rik Wasmus
Ok Rik
thanks for your help, but please tell me why this work
<?php
$string = "uno.jpg due.jpg tre.gif quattro.gif cinque.jpg";
$array = explode(' ', $string);
shuffle($array) ;
$string = implode(' ', $array);
echo $string ;
?>
and this not work
<?php
if ($handle = opendir('banner/')) {
while (false !== ($file = readdir($handle ))) {
if ($file != "." && $file != "..") {
$file = $file . " ";
$array = explode(' ', $file);
shuffle($array) ;
$file = implode(' ', $array);
echo $file;
} }
closedir($handl e);
}
?>
On Thu, 06 Sep 2007 17:26:25 +0200, pt36 <ke*********@gm ail.comwrote:
Ok Rik
thanks for your help, but please tell me why this work
<?php
$string = "uno.jpg due.jpg tre.gif quattro.gif cinque.jpg";
$array = explode(' ', $string);
shuffle($array) ;
$string = implode(' ', $array);
echo $string ;
?>
and this not work
<?php
if ($handle = opendir('banner/')) {
while (false !== ($file = readdir($handle ))) {
if ($file != "." && $file != "..") {
$file = $file . " ";
Because a file might have a space in it, and it might be a directory? It's
quite nonsense to keep juggling between an array & a string.
<?php
if ($handle = opendir('banner/')) {
$files = array();
while (false !== ($file = readdir($handle ))) {
if (is_file($file) ) $files[] = $file;
}
shuffle($files) ;
echo implode(' ',$files);
closedir($handl e);
}
?>
--
Rik Wasmus
Sorry Rik but this code not display nothing in my page
(in the directory banner I have some file)
<?php
if ($handle = opendir('banner/')) {
$files = array();
while (false !== ($file = readdir($handle ))) {
if (is_file($file) ) $files[] = $file;
}
shuffle($files) ;
echo implode(' ',$files);
closedir($handl e);}
?>
I made mistake ?
Thanks
On Thu, 06 Sep 2007 18:12:40 +0200, pt36 <ke*********@gm ail.comwrote:
Sorry Rik but this code not display nothing in my page
(in the directory banner I have some file)
<?php
if ($handle = opendir('banner/')) {
$files = array();
while (false !== ($file = readdir($handle ))) {
if (is_file($file) ) $files[] = $file;
}
shuffle($files) ;
echo implode(' ',$files);
closedir($handl e);}
?>
I made mistake ?
Nope, I did :P
<?php
$dir = './banner';
if ($handle = opendir($dir)) {
$files = array();
while (false !== ($file = readdir($handle ))) {
if (is_file($dir.'/'.$file)) $files[] = $file;
}
shuffle($files) ;
echo implode(' ',$files);
closedir($handl e);}
?>
--
Rik Wasmus
Thanks Rik now work well
Have good day This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: mike |
last post by:
If I had a date in the format "01-Jan-05" it does not sort properly
with my sort routine:
function compareDate(a,b)
{
var date_a = new Date(a);
var date_b = new Date(b);
if (date_a < date_b)
{ return -1; }
else
|
by: Jeremy |
last post by:
I want my gird to sort only the items on the current page when I click on a column header. I wrote a little test app, but when I sort it pulls in items from other pages and places them on the current page.
i.e.
If I have:
IntegerValue StringValue CurrencyValue
0 Item 0 0
1 Item 1 1.23
|
by: Kittyhawk |
last post by:
I would like to sort an Arraylist of objects on multiple properties. For
instance, I have a Sort Index property and an ID property (both integers).
So, the results of my sort would look like this:
sort index, id
1000,1
1000,2
1000,3
1001,1
1001,2
|
by: Ahmed Yasser |
last post by:
Hi all,
i have a problem with the datagridview sorting, the problem is a bit complicated so i hope i can describe in the following steps:
1. i have a datagridview with two columns (LoginName,UserName)
2. the datagridview sorting is set to automatic, so when i click on the column header is sorts well.
3. i put in an event handler for the CellEndEdit Event, so whenever the user of the program changes the content of a cell in the LoginName...
|
by: Steve Bergman |
last post by:
I'm involved in a discussion thread in which it has been stated that:
"""
Anything written in a language that is 20x slower (Perl, Python,
PHP) than C/C++ should be instantly rejected by users on those grounds
alone.
"""
I've challenged someone to beat the snippet of code below in C, C++,
or assembler, for reading in one million pairs of random floats and
| |
by: TTCEric |
last post by:
This will be original. I promise.
I cannot get the random number generator to work.
I tried seeding with Date.Now.Milliseconds, it still results in the same values.
What I have are arrays of values.
I get a random index value for each array so I can pull the data from them.
|
by: lemlimlee |
last post by:
hello,
this is the task i need to do:
For this task, you are to develop a Java program that allows a user to search or sort an array of numbers using an algorithm that the user chooses. The search algorithms that can be used are Linear Search and Binary Search. The sorting algorithms are bubble, selection and Insertion sort.
First, the user is asked whether he/she wants to perform a search option, a sort operation, or exit the program. If...
|
by: dorandoran |
last post by:
The sort on the childgrid is not working; nothing happens when I click on the each column header for sort. (I followed Satay's sample: http://www.codeproject.com/KB/aspnet/EditNestedGridView.aspx) and i am using object for datasource. please suggest.
= = = default.aspx = =
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
|
by: slapsh0t11 |
last post by:
Hello! I need help with a program that I believe I am nearly done with. However, there seems to be a few details that preclude me from success. Here is my assignment:
Here is my class file (Sorts.java):
import java.util.*;
/**
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |