cortez creations Posted February 16, 2011 Share Posted February 16, 2011 Hello All New here and could use a bit of help. Basically I have 2 separate functions that echo their results out in an html page. My problem is the first function needs a value from the second function after it has run but needs to be echoed before the second for aesthetics. Here's a bit of code to explain. <div class="bag"><br/><?php echo writeShoppingCart(); ?> </div> <div id="contents"> <?php echo showCart(); ?> </div> So basically to work correctly I need showCart to finishing before calling writeShoppingCart() I tried doing a redirect to the same page but it didn't like that. Is there another way around this that I'm not aware of? I suppose I could write a third function to get the value I need and call it before but I was hoping for a something a little cleaner. Cheers Quote Link to comment https://forums.phpfreaks.com/topic/227814-echo-functions-reverse-order/ Share on other sites More sharing options...
jcbones Posted February 16, 2011 Share Posted February 16, 2011 <div class="bag"><br/><?php $showCart = showCart(); echo writeShoppingCart(); ?> </div> <div id="contents"> <?php echo $showCart; ?> </div> Quote Link to comment https://forums.phpfreaks.com/topic/227814-echo-functions-reverse-order/#findComment-1174780 Share on other sites More sharing options...
cortez creations Posted February 16, 2011 Author Share Posted February 16, 2011 Excellent! Thanks for the speedy reply works like a charm! Quote Link to comment https://forums.phpfreaks.com/topic/227814-echo-functions-reverse-order/#findComment-1174786 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.