Jump to content

[SOLVED] basic string manipulation


HoTDaWg

Recommended Posts

lmfao im fresh outta turing so forgive me lol

here is a basic string manipulation application assigning a letter from a string onto an array:

<?php
$stringofletters = "abcdefghijklmnopqrstuvwxyz";
$letters = array();
for ($i = 1; $i <= strlen($stringofletters); $i ++)
{
$letters($i) = $stringofletters($i); #This is where the problem is
}
?>

im having trouble with pointing to a specific character in the stringofletters. here is the error im getting:

Fatal error: Can't use function return value in write context in C:\xampp\htdocs\learnphp\hacks\test.php on line 6

how do i go about referring to a specific character in the string?

Link to comment
https://forums.phpfreaks.com/topic/143211-solved-basic-string-manipulation/
Share on other sites

oh hahah thanks

thank you its a force of habit from turing:P i guess vb might have the syntax i wouldnt know.

but now im getting this error:

Fatal error: Call to undefined function abcdefghijklmnopqrstuvwxyz() in C:\xampp\htdocs\learnphp\hacks\test.php on line 6

im guessing this has to do with my inital question

here is the updated code

<?php
$stringofletters = "abcdefghijklmnopqrstuvwxyz";
$letters = array();
for ($i = 1; $i <= strlen($stringofletters); $i ++)
{
$letters[$i] = $stringofletters($i);
}
?>

how do i refer to a specific character in that string?

thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.