Wednesday 22 May 2013

Convert 123456789 string to 9,8,7,6,5,4,3,2,1 without using string function

Hello every one.

I have another chalange in php. can you convert "123456789" string to "9,8,7,6,5,4,3,2,1" this string format without using string function.

first you tell this is not possible, but this is possible using array functions. See below code.

<?php

error_reporting(0);
$str="123456789";
$a=array();
for($i=0;$i<1000;$i++)
{
if($str[$i]!="")
{
array_push($a,$str[$i]);
}
else
{
break;
}
}
$exp=array_reverse($a);
$final="";
for($i=0;$i<count($exp);$i++)
{
if($i!=count($exp)-1)
{
$final.=$exp[$i].",";
}
else
{
$final.=$exp[$i];
}
}
echo $final."<br>";

?>

Using this code you will get "9,8,7,6,5,4,3,2,1".

10 comments:

  1. Amazing…what an awesome blog! You have a way with words and how I wish I can write like you. I am starting my freelance career as a blogger on all topics under the sun. Is there a niche for writers like me who want to write on everything and anything? I found some really cool sites like video marketing online , amazing corporate brochure design, and www.freelancer.com that are the best platform for beginners like me…and of course, for the professionals. What are your thoughts on e-Marketplaces?

    ReplyDelete
  2. It is a helpful informative post. Thanks for sharing this great information. Really worth to read all info, thanks allot again. I already bookmarked this great website.

    Kids website design - Custom design for pediatric doctors designed by Optimized360.com

    ReplyDelete
  3. hey nice source for us, thanks for sharing this details and i read the whole information and it is very informative and thanks for sharing this details and i bookmark this information for future use.

    PHP Development Company

    ReplyDelete
  4. Thanks for showing the post about of php development. This post will help me to understand how php will help me to enhance my career in web development.
    Hire Xamarin Mobile app Development Company Texas USA

    ReplyDelete
  5. Hey,
    What a brilliant information you are sharing here about the relevant technology. I really appreciate your effort. I’ll visit your blog again to get some more nice information about other technologies too. Keep up the good work buddy!!
    Hire Reactjs Developers
    Hire Full Stack Developers texas
    Live Streaming SDk
    Develop Big Data Consulting Services
    Node js Development Company Texas

    ReplyDelete
  6. Woow nice blog!! Many people are looking for php web development company are you one of them ? if yes and this information for you only “intileo technologies “ one of the biggest it company in gurugram are providing various it services including php web development also!! So waiting for what just pick your mobile and call us :- 918470058143

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete