PHP Classes

Simple PHP Array: Manipulate the entries of an array

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 47%Total: 387 All time: 6,678 This week: 361Up
Version License PHP version Categories
simple-php-array 1.0GNU General Publi...3.0PHP 5, Data types
Description 

Author

This class can manipulate the entries of an array.

It wraps around an array and provides several types of functions to manipulate the array entries. Currently it can:

- Append the values of another given array to the array
- Add a value to the array at the end or at a given position
- Set an array entry at a given position to a given value
- Change all array entries with a given value to another value
- Get the positions of all array entries with a given value
- Remove array entries at a given position or with a given value
- Etc.

Picture of Sazan Dauti
Name: Sazan Dauti <contact>
Classes: 3 packages by
Country: United States United States
Age: 28
All time rank: 2813390 in United States United States
Week rank: 192 Up22 in United States United States Up

Example

<?php
//Require class file
require "simplearray.class.php";

$s = new SimpleArray;

//Load an existing array
$exArray = array("The", "is", "a", "quick", "example", "of", "loading", "an", "array");
$s->addArray($exArray);

//Manually add values
$s->add("you");
$s->add("can");
$s->add("also");
$s->add("Manually");
$s->add("add");
$s->add("values");

/*
Add array value to certain key
$s->addI(key, value);

Set array values by key
$s->set(key, value);

Change certain array values
$s->change(value);

Remove array value by key
$s->remove(key);

Remove certain array values
$s->removeV(value);

Get size of the array
$s->size();

Get array value from key
$s->get(key);

Get an array with all keys that match a certain value
$s->getV(value);

Clear an array
$s->clear();
*/

//Get the final array
$finalArray = $s->arr();

echo
"<pre>";
print_r($finalArray);

?>


  Files folder image Files (3)  
File Role Description
Accessible without login Plain text file example.php Example This is an example of how to use the class
Accessible without login Plain text file LICENSE Lic. The License
Plain text file simplearray.class.php Class The main class

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:387
This week:0
All time:6,678
This week:361Up
 User Ratings  
 
 All time
Utility:66%StarStarStarStar
Consistency:75%StarStarStarStar
Documentation:-
Examples:66%StarStarStarStar
Tests:-
Videos:-
Overall:47%StarStarStar
Rank:3095