Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Best way for first char from string ?

In php you can do stuff like this:

$string = "abcde";
$a = $string[0];

But its not working in zephir. What is best way to select first letter in string ? substr(string,0,1) or something else ?

Also it would be great if optimizer could figure out when we comparing string[0] to another string and allow it.

alphabet[(int) idx]

Weird. So it should just work ? If i use alphabet[0] then i got error about Cannot use a scalar value as an array in in php user land(it's compile fine).


Note $string should be declared as string not var.

Oh right, that's why it's not working. Well too bad :D I thought there would be some solution for var variable, cuz i have variable that can be array or string.

Well. Zephir !== PHP :)