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 4255446
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:13:13+00:00 2026-05-21T05:13:13+00:00

How can i do this $array and $object and foreach() interpretation from Php to

  • 0

How can i do this $array and $object and foreach() interpretation from Php to D correctly?

Php (pro):

class Zend_Models
{
    public static function getSome()
    {
      $array = array(
         "a" => "b",
         "b" => "b"
      );
      $object = (object) $array;

      foreach($object as $value)
      {
        $this->view->inject[] = $value;              
      }
      // Zend_Debug::dump($this->view->inject); 
      return "ok";
    }


    public static getAbove() 
    {
      return self::getSome();
    }
}

D (incubator, doing mistakes):

import std.stdio;

class Zend_Models
{
  void static getSome()
  {
    //?...
  }
}
  • 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-05-21T05:13:14+00:00Added an answer on May 21, 2026 at 5:13 am

    I think this would do it:

    import std.stdio;
    
    class Zend_Models
    {
        string getSome()
        {
              auto array = ["a", "b"];
    
              foreach(value; array)
              {
                  this.view.inject ~= value;
              }
    
              return "ok";
           } 
        }
    
        string getAbove() {
            return getSome();
        }
    }
    

    That said, you probably shouldn’t try to write PHP in D. It’s probably better to use exceptions than to return a status code, and if you do return a status code, an enum is probably better than a string.

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

Sidebar

Related Questions

I'm using a UITableView to show some data from an array. This array can
In VB6 you can do this: Dim a As Variant a = Array(1, 2,
You can initialize an array like this: int [ ] arr = { 1,
Can this be done w/ linqtosql? SELECT City, SUM(DATEDIFF(minute,StartDate,Completed)) AS Downtime FROM Incidents GROUP
I have an array like this (output from print_r ): Array ( [price] =>
While optimizing a function in PHP, I changed if(is_array($obj)) foreach($obj as $key=>$value { [snip]
How can I convert the array below Array ( [0] => stdClass Object (
Say I have an array like so in my code behind: public static string[]
Can this be done by setting a property? I'd prefer that approach then to
How can this line in Java be translated to Ruby: String className = java.util.Vector;

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.