3

Snippet below ..

function _uniord($c) {
    if (ord($c{0}) >=0 && ord($c{0}) <= 127)
      return ord($c{0});
    if (ord($c{0}) >= 192 && ord($c{0}) <= 223)
      return (ord($c{0})-192)*64 + (ord($c{1})-128);
    if (ord($c{0}) >= 224 && ord($c{0}) <= 239)
      return (ord($c{0})-224)*4096 + (ord($c{1})-128)*64 + (ord($c{2})-128);
    if (ord($c{0}) >= 240 && ord($c{0}) <= 247)
      return (ord($c{0})-240)*262144 + (ord($c{1})-128)*4096 + (ord($c{2})-128)*64 + (ord($c{3})-128);
    if (ord($c{0}) >= 248 && ord($c{0}) <= 251)
      return (ord($c{0})-248)*16777216 + (ord($c{1})-128)*262144 + (ord($c{2})-128)*4096 + (ord($c{3})-128)*64 + (ord($c{4})-128);
    if (ord($c{0}) >= 252 && ord($c{0}) <= 253)
      return (ord($c{0})-252)*1073741824 + (ord($c{1})-128)*16777216 + (ord($c{2})-128)*262144 + (ord($c{3})-128)*4096 + (ord($c{4})-128)*64 + (ord($c{5})-128);
    if (ord($c{0}) >= 254 && ord($c{0}) <= 255)    //  error
      return FALSE;
    return 0;
  }   //  function _un

From the code which includes ord($c{0}) I never seen before, can anyone tell me what does this mean? I google a lot and find nothing.

johnny_trs
  • 233
  • 1
  • 2
  • 6
  • Either answer work for you? http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work – chris85 Sep 30 '16 at 17:42
  • Well looking at your history I guess you don't accept answers. – chris85 Oct 13 '16 at 03:23
  • @chris85 Sorry,I did not know the rules,so how to accept this answers? (just tell me the steps) – johnny_trs Oct 17 '16 at 02:22
  • There is a checkmark on the left side of each answer. The linked thread has images of where it is if you cant find it, http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work. You also should accept answers on your other questions, if they have answers that worked for you. – chris85 Oct 17 '16 at 02:36

2 Answers2

4

That is another way of accessing array elements.

$c{0} and $c[0] will function the same.

Both square brackets and curly braces can be used interchangeably for accessing array elements

-http://php.net/manual/en/language.types.array.php

Demo: https://eval.in/652193

chris85
  • 23,846
  • 7
  • 34
  • 51
2

just like '[]',

<?php
$aa = array(1, 2);
echo $aa{1};
echo $aa[1];

will output

2
2
LF00
  • 27,015
  • 29
  • 156
  • 295