String access and modification by character is possible in PHP. What you need to know, and probably didn't know is that while strings are expresses as string, sometimes they can be considered as arrays: let's look at this example:
$text = "The quick brown fox...";
Now, if you were to echo $text[0]
you would get the first letter in the string which in this case happens to be T
, or if you wanted to modify it, doing $text[0] = "A";
then you will be changing the letter "T"
to "A"
Here is a good tutorial from the PHP Manual, It shows you how strings can be accessed/modified by treating them as an array.
<?php
// Get the first character of a string
$str = 'This is a test.';
$first = $str[0];
// Get the third character of a string
$third = $str[2];
// Get the last character of a string.
$str = 'This is still a test.';
$last = $str[strlen($str)-1];
// Modify the last character of a string
$str = 'Look at the sea';
$str[strlen($str)-1] = 'e';
?>
BTW: If you had only wanted to display, the first value inside your array, you could use something like
<?php
$ar = array("some text","more text","yet more text");
for ($i=1; $i<=1; $i++)
{
echo $ar[0];
}
?>