L
L
Looking2015-03-05 22:18:37
PHP
Looking, 2015-03-05 22:18:37

What is the analogy in PHP?

In C++:
list *adj = new list[V];
adj[v].push_back(w);
What can be composed from an array similar or something else?
I tried using SplDoublyLinkedList but it won't work like this adj[v].push_back(w)
How can I save data in the same form in php?
UPD:
I'll try to put the question differently, because the problem is most likely not in this.
Here is the C++ code , I need to rewrite it in php. Here is what I wrote PHP code
But it doesn't work. Writes that the recursion has crossed a possible threshold.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
D
Denis, 2015-03-06
@Looking

65 (cpp) a = b = ++time;
37 (php) a = b; // a = b = ++Graph::$time; ?
At a cursory glance, you are sending to the infinite recursion in line 49 (php). $u (aka $v), then 1, then 0, then 1, then 0...
I could be wrong, but it seems the problem is in line 37 of the php code.

F
FanatPHP, 2015-03-05
@FanatPHP

you either delete the PHP tag, and wait for answers only from sipipishnikov, or explain clearly what you need.

A
Alexander, 2015-03-05
Obiedkov @aobiedkov

php.net/manual/en/function.array-push.php

P
Philipp, 2015-03-05
@zoonman

As far as I understood, you need to add elements to the end of the array. It is done like this:

$myArray = []; // объявляем массив
$myArray[] = 'custom value'; // добавит элемент в конец массива

S
Sergey, 2015-03-06
Protko @Fesor

$adj = [];
array_push($adj, $w);
// или
$adj[] = $w;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question