otuatail Posted November 17, 2007 Share Posted November 17, 2007 Can anyone tell me how to add extra strings to an exsisting array $data = array("AAA","BBB","CCC"); $data . "DDD"; // dosn't work. Desmond. Quote Link to comment Share on other sites More sharing options...
thebadbad Posted November 17, 2007 Share Posted November 17, 2007 Simple: <?php $data = array("AAA", "BBB", "CCC"); array_push($data, "DDD"); ?> Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 17, 2007 Share Posted November 17, 2007 Simple: <?php $data = array("AAA", "BBB", "CCC"); array_push($data, "DDD"); ?> also you can do $data[] = "DDD"; Quote Link to comment Share on other sites More sharing options...
thebadbad Posted November 17, 2007 Share Posted November 17, 2007 Hehe, even simpler But you can't add multiple strings that way, right? Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 17, 2007 Share Posted November 17, 2007 Yep thats why I quoted your post just giving options Quote Link to comment Share on other sites More sharing options...
otuatail Posted November 17, 2007 Author Share Posted November 17, 2007 Thanks for that. (Hehe, even simpler But you can't add multiple strings that way, right?) wasn't my reply though. Both examples work fine thanks. One thing is there a function to search an aray for a value or do i have to iterate through the entire string. Can't find a usefull function. Desmond. Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 17, 2007 Share Posted November 17, 2007 you can use array_search function more information at http://php.net/array_search Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.