Strong array syntax

I am trying to understand how the function I was given works - or rather, does not work. Problem areas include writing an array as follows:

$small[$end[$i]{0}] 

I think the idea is to add "0" to the value of $end[$i] and use it for the index $ small. But this does not work in PHP5.3. Is this obsolete syntax and is it trying to do what I think?

+6
arrays syntax php
source share
1 answer

It gets the first character from the string $end[$i] , and then accesses the $small array, using that character as the key to the array.

Edit:

Since $foo=200; $foo[0] != 2;//=='' $foo=200; $foo[0] != 2;//=='' , what do you recommend to get the leftmost digit when the value of the number is unknown?

The easiest way is substr($foo, 0, 1) in PHP.

If you use a strongly typed language, I have some indicators that may interest you in reading from my other answer: How can you get the first digit in int (C #)?

+9
source share

All Articles