0

Strangely enough I haven't found any question or answers to my problem (should be quite basic), so I will ask it here.

in PHP If I have an array named myArray that I don't know the contents of, then I can't do this:

$myArray[20] = "some string";

because entry 20 may already exist.

So is there a way to automatically insert a string as the last entry, so nothing is overwritten in the array?

2

1 Answer 1

1

You could just add the new item to your array like:

$myArray[] = "some string";

This would automatically add it to the end of your existing array without overwriting existing array entries.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.