DlGar_26 Posted July 25, 2012 Share Posted July 25, 2012 Hello Community I'm a newbie with coding , so i hope you guys can help me out so i have for example 3 iframe codes1. <iframe src="http://www.google.com"></iframe>2. <iframe src="http://www.yahoo.com"></iframe>3. <iframe src="http://www.bing.com"></iframe> so i want to shuffle these 3 iframes but i do not know how ?i have tryed using this code but a total fail <?php$iframe = array(); $iframe[0] = '<iframe src="http://www.google.com"></iframe>'; $iframe[1] = '<iframe src="http://www.yahoo.com"></iframe>'; $iframe[2] = '<iframe src="http://www.bing.com"></iframe>';shuffle($iframe);echo $iframe[0];?> it did not worked for me , do you have any idea how to get it work ? Regards Link to comment Share on other sites More sharing options...
justsomeguy Posted July 25, 2012 Share Posted July 25, 2012 I don't see a problem with that code. Link to comment Share on other sites More sharing options...
DlGar_26 Posted July 25, 2012 Author Share Posted July 25, 2012 Hello "justsomeguy" thank you for your fast reply . that's a bit embarrassing .when i use the code first it doesn't shuffle them and second it shows all 3 iframes which i don't want , i want 1 iframe to be shown that got shuffled from those 3 iframes available in the code is there any other option/script i might use ? Link to comment Share on other sites More sharing options...
justsomeguy Posted July 25, 2012 Share Posted July 25, 2012 The code you showed should do what you say you want to do. I don't see how that code would print all 3 elements, you're only telling it to print 1. Unless that's not the entire code. Link to comment Share on other sites More sharing options...
DlGar_26 Posted July 26, 2012 Author Share Posted July 26, 2012 Hello i have found the problem , problem was that this code should start in an .html file which the php code could not be read properly.so i creat a .php file and add the code there and called it with an another iframe in the .html file, now its working my problem was that i wantet to run a .php code in a .html file and this is the complete code <?php$iframe = array();$iframe[0] = '<iframe src="http://www.bing.com" allowtransparency="true" frameborder="0" scrolling="auto" rel="nofollow" style="width:100%;height:100%"></iframe>';$iframe[1] = '<iframe src="http://www.google.com" allowtransparency="true" frameborder="0" scrolling="auto" rel="nofollow" style="width:100%;height:100%"></iframe>';$iframe[2] = '<iframe src="http://yahoo.com" allowtransparency="true" frameborder="0" scrolling="auto" rel="nofollow" style="width:100%;height:100%"></iframe>';$numbers = range(0, 2);shuffle($numbers);foreach ($numbers as $number):endforeach;echo $iframe[$number];?> Thank you Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now