Skip to content

Instantly share code, notes, and snippets.

View phpfact's full-sized avatar
🎯
Focusing

Sachin Sharma phpfact

🎯
Focusing
View GitHub Profile
<!--
<input type="text" name="reading_paper_marks[1]">
<input type="text" name="reading_paper_marks[2]">
<input type="text" name="reading_paper_marks[3]">
-->
<script>
$( "input[name='reading_paper_marks[1]']" ).val(2);
</script>
<?php
#01 - array_key_first
$myArr = ['name'=> 'sachin', 'phone' => '1234'];
echo array_key_first($myArr); // name
echo $myArr[array_key_first($myArr)]; // sachin
#02 - array_key_last
$myArr = ['name'=> 'sachin', 'phone' => '1234'];
<?php
// The date
$plain_date = '2022-09-21 09:00:00';
// Prepare the timezones
$datetime_TO = new DateTimeZone('Asia/Kolkata'); // TO // India (+05:30) = +0530 = Asia/Kolkata
$datetime_FROM = new DateTimeZone('Asia/Singapore'); // FROM // Singapore (+08:00) = +0800 Asia/Singapore
//OR
<form>
<input type="date" name="meeting_date" value="<?= isset($_GET['meeting_date']) ? $_GET['meeting_date'] : '' ?>">
<br><br>
<input type="time" name="meeting_time" value="<?= isset($_GET['meeting_time']) ? $_GET['meeting_time'] : '' ?>">
<br><br>
// Think Client, Enter Think Client, Ashish Bali
https://drive.google.com/drive/folders/1ibOszWmn4hJuN3ux27GdAnA73ViAaCEp?usp=sharing
@phpfact
phpfact / dev note.php
Last active September 12, 2022 08:24
/* Development NOTES */
1. Every Table has prefix with vt_ (vt_users, vt_settings.....)
2. Model m updated event call hone pr table m updated_at m current epoch time save ho jaye
3. Model m created event call hone pr table m created_at m current epoch time save ho jaye.
/*
Name route connect
<?php
#Route
$routes->post( 'is-auth', 'Home::loginAuthCheck', ['as' => 'ajax.is-auth'] );
#Controller
public function loginAuthCheck()
{
$Login = 'no';
if ( empty( session()->get( 'last_login_token' ) ) ) {
$Login = 'no';
<?php
function fixForUri($string){
$slug = trim($string); // trim the string
$slug= preg_replace('/[^a-zA-Z0-9 -]/','',$slug ); // only take alphanumerical characters, but keep the spaces and dashes too...
$slug= str_replace(' ','-', $slug); // replace spaces by dashes
$slug= strtolower($slug); // make it lowercase
$slug = preg_replace('/-+/', '-', $slug); // replace ---- to -
return $slug;
<!-- dynamically set the selected option of a drop-down list using jQuery, JavaScript and HTML -->
<script>
// Dynamically Select User Current Time Zone
$(function(){
let mtz = Intl.DateTimeFormat().resolvedOptions().timeZone;
$("#schedule_meeting_timezone").val(mtz).attr("selected","selected");