Posts

Showing posts from 2018

Calculate digonal difference in php array matirx

$arr = array(       array(11, 2, 4),     array(4, 5, 6),     array(10, 8, -12), ); echo diagonalDifference($arr); function diagonalDifference($arr) { $n= count($arr); $firstdsum= 0; $seconddsum = 0; $i = 0; for($j = 0; $j < $n; $j++){     $firstdsum+= $arr[$i++][$j];     $seconddsum += $arr[$n- $i][$j]; } return  abs($firstdsum- $seconddsum ); }

Laravel 5.7.15 Released on 28 november

New validation rule and Eloquent relationship getters are available in new laravel 5.7.15 — first, the starts_with validation rule which allows you to check that an input starts with a string. $request->validate([ 'greeting' => 'starts_with:hello', ]);  pass multiple strings, in which the rule will pass if at least one matches the input: $request->validate([ 'greeting' => 'starts_with:hello,hola', ]); the date_equals validation rule is now translatable, and you should update your resources/lang/en/validation.php file with the following: 'date_equals' => 'The :attribute must be a date equal to :date.', New relationship getters are available in this release including: BelongsToMany::getParentKeyName BelongsToMany::getRelatedKeyName HasManyThrough::getFirstKeyName HasManyThrough::getForeignKeyName HasManyThrough::getSecondLocalKeyName

CodeIgniter 4.0.0-alpha.3 released

Release highlights: Numerous bug fixes, across the framework Many missing features implemented, across the framework Code coverage is up to 72% CodeIgniter4 has been promoted to its own github organization. That is reflected in docs and comments. We have integrated a git pre-commit hook, which will apply the CI4 code sniffer rules, and attempt to fix them. We have run all the source files through it, and any "funny" code formatting is temporary until the rules are updated. We welcome Natan Felles, from Brazil, to the core CodeIgniter4 developer team. He has proven to be passionate, dedicated and thorough

generate unique random number using sql query

SELECT FLOOR(RAND() * 99999) AS random_num FROM numbers_mst  WHERE "random_num" NOT IN (SELECT my_number FROM numbers_mst) LIMIT 1 Selects random number between 0 - 1 using RAND(). Amplifies that to be a number between 0 - 99999. Only chooses those that do not already exist in table. Returns only 1 result.

Codeigniter Hmvc Modules Naming

Go to the Application/config/config.php and define Module location in $config [ 'modules_locations' ] and you are able to access the different location modules in code igniter. $config [ 'modules_locations' ] = array ( APPPATH . 'modules/' => '../modules/' , APPPATH . 'modules/frontend/open/' => '../modules/frontend/open/' , APPPATH . 'new/' => '../new/' , );