Jump to content

Recommended Posts

"[]" is deprecated in favour of "{}" when pulling a character from a string.

 

$first = $str{0};

 

You got it the other way around Barand... From strings:

Characters within strings may be accessed and modified by specifying the zero-based offset of the desired character after the string using square array-brackets like $str[42] so think of a string as an array of characters.

 

    Note: They may also be accessed using braces like $str{42} for the same purpose. However, using square array-brackets is preferred because the {braces} style is deprecated as of PHP 6.

 

 

Orio.

Link to comment
https://forums.phpfreaks.com/topic/83272-display-1st-character/#findComment-423638
Share on other sites

I know, I just checked the online manual.

 

In my .chm version of the manual which I download

 

Characters within strings may be accessed and modified by specifying the zero-based offset of the desired character after the string in curly braces.

 

????: For backwards compatibility, you can still use array-brackets for the same purpose. However, this syntax is deprecated as of PHP 4.

 

Wish they'd make up their mind !

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/83272-display-1st-character/#findComment-423642
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.