I am struggling with understanding what array function would work best for my particular situation. There seems to be a vast amount of confusion from others as well as I have read several posts. I have two arrays with different structures but both contain an ID field I would like to compare. Array one is my f…
{Carbon} Convert time in HH:MM:SS format into seconds in Laravel?
I want to convert the time which I got from $scheduleTime = Carbon::createFromTimestampUTC($scheduleTimestamp)->toTimeString(); which is currently giving me 07:32:40 now I want to convert it into …
Create affliate URL in PHP
I’m trying to create an affiliate url like http://example.com/ref/referrer. I have 2 php files and a .htaccess file. I have a database table called ‘referral’ that stores username of users in a field …
Add order column to array to indicate rank from oldest to youngest
In PHP7, If I have this array: What is the most elegant way to process this array to add an extra column indicating who is the oldest to who is the youngest like so… Answer Without a point of reference to determine which is the oldest user you’re stuck either doing a multi loop comparison or a sor…
localization FakerFactory does not work in laravel
I have a Post Model with these fields : Now I want to use laravel sedders and model factories to create fake fa_IR localized data and insert to posts table. For that I wrote this in database/factories/ModelFactory.php: Then I created a PostsTableSeeder class like this : And in AppServiceProvider.php added bel…
PHP Fetch image from DM Twitter using REST API?
I have problem when I want to fetch image that was sent to my DM. So when I fetch the DM data from API, I got the media id for the image but how to fetch it? I want to fetch the image and tweet it to …
remove part of string after delimiter in php
I have seen other I have a string ” cccc cccc – fff” I need to return “cccc cccc” I don’t need to delimiter too I tried to echo the result of substr($mystring , 0, strpos($mystring , “-“)); but it return nothing I also tried resulted returned the main string and…
php post value from FOREACH to another page
I’ve never asked any question here before, but after spending many hours searching for a hint I decided to ask a question. I have a project at school where I need to create a table from DB for all …
Allowing video to be played in element from my website, but not allowing it through direct link
I used the below tricks: First, I disabled the right click in order to prevent the user from using save as or get link using this HTML5: Second: I used the controlsList=”nodownload” but the problem it works fine ONLY in Chrome 58+ as per this, later on I may consider customs control as shown here …
Laravel active menu item for url included parameters
I’m trying to set active class in my list item, but it doesn’t work. My code in blade: So, if I write: li class=”@if(getRouteName() == ‘site@index’){{ ‘active’ }}@endif” , it works nice, but in my case the problem is that I want to get ‘active’ class…