Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8843941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:21:42+00:00 2026-06-14T11:21:42+00:00

I would like to convert the following code from php to JavaScript: $price =

  • 0

I would like to convert the following code from php to JavaScript:

$price = '270';

$allowed_sms_prices = array(
 5,7,10,15,20,25,30,35,39,40,
 45,49,50,55,59,60,69,75,79,85,
 89,95,100,125,150,175,200,225,250,275,
 300,310,315,320,325,330,335,340,345,350,
 355,360,365,370,375,380,385,390,395,400,
 405,410,415,420,425,430,435,440,445,450,
 455,460,465,470,475,480,485,490,495,500
);

while( ! in_array( $price, $allowed_sms_prices ) )
{
     $price = $price + 1;
}
echo $price;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:21:43+00:00Added an answer on June 14, 2026 at 11:21 am

    Here is a javascript equivalent:

    $price = 270;
    
    $allowed_sms_prices = Array(
     5,7,10,15,20,25,30,35,39,40,
     45,49,50,55,59,60,69,75,79,85,
     89,95,100,125,150,175,200,225,250,275,
     300,310,315,320,325,330,335,340,345,350,
     355,360,365,370,375,380,385,390,395,400,
     405,410,415,420,425,430,435,440,445,450,
     455,460,465,470,475,480,485,490,495,500
    );
    
    while( $allowed_sms_prices.indexOf($price) == -1 )
    {
         $price = $price + 1;
    }
    alert($price);
    

    See how easy that was?

    There is still a problem with your logic, namely that there is no reliable exit condition for the loop. For example, if the $price value was greater than 500, the loop would run indefinitely. There are several approaches you could take that could correct this, one of which is to check if the value is not larger than the greatest value in the array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to convert the following string into an array/nested array and iterate
I would like to convert / form the following arrays as example: Array (
I would like convert the below text into a nested array, something like you
I would like to convert from a set to a List within a method
I would like to convert a Dictionary to a string array (or list) The
I would like to convert from an image (like jpg or png) to PDF.
I have the following time: 20111122050940.086000 and I would like to convert to seconds,
i'm trying to convert the following code from Java to C#. // Replace 0
I am trying to convert the following LINQ code from C# to VB.NET. Here
I have the following code, and I'd like to get away from the call-time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.