N
N
Ninazu2016-05-06 20:32:39
PHP
Ninazu, 2016-05-06 20:32:39

Is there an analogue in PHP of the std::pair function?

for (const std::pair<uint32_t, Parameter>& p : m.parameters)
    {
        QString start = QString::fromUtf8(p.second.start.c_str());
        m_parameters[p.first] = value;
        m_parametersVisibility[p.first] = true;
    }

Help translate to PHP

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
AtomKrieg, 2016-05-06
@Ninazu

something like this, correct minor errors yourself

//for (const std::pair<uint32_t, Parameter>& p : m.parameters)
foreach ($m->parameters as $k => $v) {
//QString start = QString::fromUtf8(p.second.start.c_str());
  $start = $v->start;
// m_parameters[p.first] = value;
  $this->m_parameters[$k] = $value;
// m_parametersVisibility[p.first] = true;
  $this->m_parametersVisibility[$k] = True;
}

M
Maxim Moseychuk, 2016-05-06
@fshp

Pair is not a function, but a pair (double tuple).
The for(v:a) construct iterates over the elements of the container. m.parameters can be a list, vector, array of pairs. But most likely it is an associative array. In a pair, the first element is the key, the second is the value.
I don’t know about php, but Google says about each.

A
Alexander Aksentiev, 2016-05-06
@Sanasol

foreach

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question