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
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

Link to comment
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.