php

imap_search limit the number of messages returned

笑着哭i 提交于 2021-02-18 10:29:45
问题 I have PHP script that fetch messages from a mailbox. I use the imap_search function: $emails = imap_search($mbox, 'UNSEEN'); Is there a way to limit the number of returned messages. Right now on huge mailboxes i get like 5000 messages. I want only the top 20 ordered by date. Is there a way to do that? Thanks. 回答1: The imap_search function has a CRITERIA attribute you can use to limit the messages in a number of ways: ALL - return all messages matching the rest of the criteria ANSWERED -

PHP : multidimensional array merge recursive

牧云@^-^@ 提交于 2021-02-18 10:25:29
问题 I need to merge those two arrays: $ar1 = array("color" => array("red", "green"), "aa"); $ar2 = array("color" => array( "green", "blue"), "bb"); $result = array_merge_recursive($ar1, $ar2); Expected output: [ 'color' => [ (int) 0 => 'red', (int) 1 => 'green', (int) 3 => 'blue' ], (int) 0 => 'aa', (int) 1 => 'bb' ] But it outputs: [ 'color' => [ (int) 0 => 'red', (int) 1 => 'green', (int) 2 => 'green', (!) (int) 3 => 'blue' ], (int) 0 => 'aa', (int) 1 => 'bb' ] I'm looking for the simplest way

Laravel Model Factory without connection to database

感情迁移 提交于 2021-02-18 10:12:23
问题 I would like to use Laravel's Model Factory in some PHPUnit tests. The only thing I want to do is make a Model instance without saving it to database. Why the Model Factory needs connection to database? These tests must pass on CI environment without configured database. When I create Model manually by new App\Model($dataArray) , tests pass and the connection is not needed. I am using Model Factory in other places, so I would like to reuse it in that tests, to avoid code duplication. I am

Laravel Model Factory without connection to database

為{幸葍}努か 提交于 2021-02-18 10:10:34
问题 I would like to use Laravel's Model Factory in some PHPUnit tests. The only thing I want to do is make a Model instance without saving it to database. Why the Model Factory needs connection to database? These tests must pass on CI environment without configured database. When I create Model manually by new App\Model($dataArray) , tests pass and the connection is not needed. I am using Model Factory in other places, so I would like to reuse it in that tests, to avoid code duplication. I am

PHP intl country code 2 chars to country name

不问归期 提交于 2021-02-18 08:59:30
问题 I'm triying to convert, using PHP, 2 characters country code (ISO 3166-1) to country names, or intl country codes, so I can translate the country name. Using Locale::getDisplayRegion needs locale codes for languages ( nl_NL ) and all I have is the 2 characters country code. I don't want to rely on Webservices, but I can think on the geoip extension (I can't find a solution using it anyway) Is there any way to get the 2 chars country code and convert it to localiced country name in PHP without

Laravel : advanced search form query

杀马特。学长 韩版系。学妹 提交于 2021-02-18 08:35:54
问题 I have an advanced search form to filter out results from a database using Laravel. The data is filtered correctly but I have a requirement for the user to be able to filter by first name or last name using the same text box (in the advanced form). I tried orWhere to make sure it filters the name field with the first name or last name but the orWhere doesn't consider the other filters. The code I am using is as follows: DB::table('mytable') ->where(function($query) use ($name, $degree_s,

Laravel : advanced search form query

限于喜欢 提交于 2021-02-18 08:35:32
问题 I have an advanced search form to filter out results from a database using Laravel. The data is filtered correctly but I have a requirement for the user to be able to filter by first name or last name using the same text box (in the advanced form). I tried orWhere to make sure it filters the name field with the first name or last name but the orWhere doesn't consider the other filters. The code I am using is as follows: DB::table('mytable') ->where(function($query) use ($name, $degree_s,

Additional columns and item values in Woocommerce email order details

假如想象 提交于 2021-02-18 08:03:24
问题 I am editing a Woocommerce email template but am a little stuck - I need to add a few columns to the order summary table so that it contains: Quantity Product Product code Price VAT I have added the table headers that I need into 'email-order-details.php' (copied to my theme's email folder) to but not sure how to get the actual content into the table. The code from the file is below: <?php /** * Order details table shown in emails. * * This template can be overridden by copying it to

Additional columns and item values in Woocommerce email order details

爱⌒轻易说出口 提交于 2021-02-18 08:03:24
问题 I am editing a Woocommerce email template but am a little stuck - I need to add a few columns to the order summary table so that it contains: Quantity Product Product code Price VAT I have added the table headers that I need into 'email-order-details.php' (copied to my theme's email folder) to but not sure how to get the actual content into the table. The code from the file is below: <?php /** * Order details table shown in emails. * * This template can be overridden by copying it to

How would you organize mails in a multilingual Laravel application

こ雲淡風輕ζ 提交于 2021-02-18 08:03:00
问题 I'm curious about how to effectively generate emails in a multilingual application. For the sake of getting all answers aligned: let's say you have a typical commercial newsletter with lots of images, markup, and of course many textual paragraphs. Assume that all text does NOT come from a database but should be hard-coded. Moreover, some words in these paragraphs can be bolded, emphasized,... The newsletter will be sent in the subscriber's preferred locale. How can I build a system to handle