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

  • SEARCH
  • Home
  • 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 8071429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:41:33+00:00 2026-06-05T13:41:33+00:00

Trying to convert a perl script to php. In perl I have a hash

  • 0

Trying to convert a perl script to php.

In perl I have a hash like this

my %SPEC=(
odmiles           => ['OD Miles','Mileage','odmiles:ecmmiles','num'],
ecmmiles          => ['ECM Miles',0,'','num',' ECM'],
cdl               => ['CDL','CDL']);

I can access the data like so:

$SPEC{ecm}[3]  # output = num

Since a hash in perl does not run in order I’ll do a simple array

@ORD=('odmiles','ecmmiles','cdl');

then loop

foreach my $S (@ORD) {
  print $S." = ".$SPEC{$S}[0]."<br />";
  }

I can do similar with php but having issue accessing elements past [0] in my hash.

  • 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-05T13:41:34+00:00Added an answer on June 5, 2026 at 1:41 pm

    I think you’re looking for this:

    $SPEC = array(
      'odmiles'           => array('OD Miles','Mileage','odmiles:ecmmiles','num'),
      'ecmmiles'          => array('ECM Miles',0,'','num',' ECM'),
      'cdl'               => array('CDL','CDL')
    );
    

    Accessing elements would then work something like this:

    echo $SPEC['odmiles'][0]; // 'OD Miles'
    echo $SPEC['odmiles'][1]; // 'Mileage'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to convert a Perl script to a C# 3.5 routine. The
I'm pretty new to Perl and trying to convert some PHP code to Perl.
I'm trying to convert a hash to a XML-string with this module XML::Hash::LX but
I'm trying to convert a Perl script to python, and it uses quite a
Im trying to convert this php function to javascript: function sanitize_words($string,$limit=false) { preg_match_all(/\p{L}[\p{L}\p{Mn}\p{Pd}'\x{2019}]{1,}/u,$string,$matches,PREG_PATTERN_ORDER); return
Trying to convert this c code into MIPS and run it in SPIM. int
I'm trying to convert std::string to float/double . I tried: std::string num = 0.6;
I have a file, someFile , like this: $cat someFile hdisk1 active hdisk2 active
I'm trying to convert the variable $num into its reverse byte order and print
I'm trying to port the following php functionality over to perl: public function loadKey($mod,

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.