Learn 10 programming languages side by side, guided by the PHP manual

One PHP function — see how all 10 languages write it

See the comparison in one example

Take array_map: the same "multiply every element by 2" in PHP / Python / Go / Rust — four real snippets side by side (code and output copied from the entry data; see the entry page for the full comparison).

PHP
echo json_encode(array_map(fn($x) => $x * 2, [1, 2, 3]));

Output

[2,4,6]
Python
print(list(map(lambda x: x * 2, [1, 2, 3])))

Output

[2, 4, 6]
Go
package main

import "fmt"

func main() {
    a := []int{1, 2, 3}
    b := make([]int, len(a))
    for i, v := range a {
        b[i] = v * 2
    }
    fmt.Println(b)
}

Output

[2 4 6]
Rust
fn main() {
    let v: Vec<i32> = vec![1, 2, 3].iter().map(|x| x * 2).collect();
    println!("{:?}", v);
}

Output

[2, 4, 6]

See the full 10-language comparison of array_map →

10 languages · all outputs verified by real execution · new entries added continuously

Browse by category