Skip to content

oceanbeedev/phparray

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

PHP Array CRUD Operation

Setup

inclue ObArray.php to your project

how to use ?

very simple !

Example

#push in array

<?php 
    
    	inclue "ObArray.php" ;
		
	$array = [
		[
		  'nmae'=>'..' ,
		  'family'=>'..'
		]
      	] ;
      
      	$data = ObArray::push($array,[
		[
		  'name'=>'hadi' ,
		  'family'=>'hosseini'
		],
		[
		  'name'=>'ali' ,
		  'family'=>'karimi'
		]
      	]);	
	
	
	
#read data using where -----------------

	$array = [
		  'name'=>'hadi' ,
		  'family'=>'hosseini'
		],
		[
		  'name'=>'ali' ,
		  'family'=>'karimi'
		]
	];
	
	$params = (object)[
		'name'=>'hadi'
	] ;
	
	$data = ObArray::where($array,function($item,$params){
		$status = false ;
		if($item->name == $param->name){
			$stauts = true ;
		}
		return ['status'=>$status];
	},$params) ;
	
	
#or :

$data = ObArray::findBy($array,'name','hadi');



#order by array---------------
$data = ObArray::orderBy($array,'name','asc');

#group by array -------------------
$data = ObArray::groupBy($array,'name');

#update array---------------
$data = ObArray::update($array,ObArray::where(function($item,$params){
	$status = false ;
		if($item->name == $param->name){
			$stauts = true ;
		}
		return ['status'=>$status];
},(object)[
	'name'=>'hadi'
]),[
	'name'=>'hadi 2'
]);



#delete from array ----
$data = ObArray::delete($array,ObArray::where(function($item,$params){
	$status = false ;
		if($item->name == $param->name){
			$stauts = true ;
		}
		return ['status'=>$status];
},(object)[
	'name'=>'hadi'
]);



#pagination array data 

$limit = 2 ;
$page = 1 ;

$data = ObArray::limit($array,$limit,$page);











	

About

php array CURD opration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages