Hi all looking for a little help.
I've created a site which shows the previous form of soccer teams like so:
This works fine and each letter is output by PHP as an image.
The problem is that the only way I could get my head round it to work it out was to create a custom field of checkboxes in Wordpress like so:
What would probably work better would just to have a textbox on the backend where I could just type in the form like "WLDWW" and then the front end display as necessary.
Problem is that I'm not entirely sure where to start with PHP for it to read each individual letter that I put into the textbox and translate that into the image needed at the front end.
Any ideas?
Thanks in advance
Take a look at str_split(). (see here)
$string = "WLWLLW";
$result = str_split($string);
This will output:
Array
(
[0] => W
[1] => L
[2] => W
[3] => L
[4] => L
[5] => W
)
Then you can iterate through the array and display as needed, if you want to use PHP. Of course, I don't know how you've implemented it exactly or how it uses Wordpress, so you may have to make some adjustments as needed.
Related
I've tried searching all over google and tried a similar problem and answers yet I still didn't get my problem done.
So basically, I'm making an HTML to write user input in a textbox which is the user would input:
Dog,
cat,
coronavirus,
Fever,
Cough,
Then into my PHP code, I capture it with:
$input = $_GET['contents'];
So I tried this one which I saw from googling and it doesn't have an explanation but logically its about array:
$input= explode(array(",", ""), $input)[0];
It works but the problem is that it only shows the first output which is:
Dog
Dog
Dog
Dog
Dog
But when I tried to remove the delimiter code, it shows one string only:
Dog,cat,coronavirus,Fever,Cough,
I thought about it something related to array but I'm not sure, is there any way to display all of them per line and with the help with delimiter?
UPDATE:
So I tried doing print_r($secs); and it shows like this:
Array ( [0] => Dog [1] => cat )
Array ( [0] => )
My accomplishment is to read all of the arrays one by one in another line instead of joining it as one strings. Sorry for bad english and im trying my best to explain.
you do not need the array() line.
Instead
if(strpos($_GET['contents'],',') !== false) { //check for commas first
$input = explode(',' , $_GET['contents']);
echo '<pre>';
print_r($input); //gives you the array
echo '</pre>';
}
to access each string individually, call the offset. For example, print_r($input[0]);
Also a friendly piece of advice. You seem like a beginner. You do not have to execute multiple commands in one line. Write your code step by step.
I want to extract the name from a paragraph or text content. I am using PHP. I tried to extract the name from below library.
https://packagist.org/packages/php-text-analysis/php-text-analysis
https://packagist.org/packages/php-text-analysis/php-text-analysis
$text = "my name is maneesh, and my friend name is Paritosh";
$freqDist = freq_dist(tokenize($text));
print_r($freqDist); die;
My expected output is : maneesh, Paritosh
Actual result is getting only frequency of word:
(
[my] => 2
[name] => 2
[is] => 2
[maneesh] => 1
[and] => 1
[friend] => 1
[Paritosh] => 1
)
If you are going to use the library you mentioned, you have to train your model. That means, fill them with many possible ways in which people can say their name. But even so, I wouldn't be perfect (depends on how well you trained your model).
Moreover, you are getting only frequency of words because that's the analysis you requested with the method freq_dist. I think you have to use corpus analysis for what you want.
I'm using Evernote's PHP SDK and I need to retrieve a list of tagged notes.
When I filter by keyword or notebook giud it works, but as soon as I set tagGuids i get empty list.
Here's sample code:
$noteFilter=new EDAM\NoteStore\NoteFilter();
#For the sake of this example, I'm just getting all existing tags
#and adding them to filter so it should:
$tags=$noteStore->listTags($token);
$noteFilter->tagGuids=Array();
foreach($tags as $tag){
$noteFilter->tagGuids[]=$tag->guid;
}
$notes=$noteStore->findNotes($token,$noteFilter,0,20);
I have notes with tags. But this is what i get in result, an empty list:
EDAM\NoteStore\NoteList Object
(
[startIndex] => 0
[totalNotes] => 0
[notes] => Array
(
)
[stoppedWords] =>
[searchedWords] =>
[updateCount] => 139
)
Actually, you can't do this kind of search. Using the tagGuids property with - let's say - 2 tags will lead to search for notes containing these 2 tags at the same time.
It's an 'AND' search, not an 'OR' search.
One option would be to make several searches, each with one tag and merging the results...
Not optimal but I'm afraid it's the only solution you have.
You may find some help here : https://dev.evernote.com/doc/articles/search_grammar.php
BTW, the findNotes methods is deprecated. You should use the findNotesMetadata method :
$resultSpec = new \EDAM\NoteStore\NotesMetadataResultSpec();
$resultSpec->includeTitle;
$resultSpec->includeTagGuids;
$notes=$noteStore->findNotesMetadata($authToken,$noteFilter,0,20, $resultSpec);
While working with the cakephp, I found an issue mentioned below.
Fetched the encrypted field info from DB (encrypted using Security::rijndael)
Passed this whole data as an array format to the custom Library(Own created lib).
When i echoed the data in lib as well in controller I amazed to see the result. The value (encrypted one) are showing blank in the lib. Is I missed anything in codding? I searched on google but didn't get the satisfactory answer, Please help me out. Your help will really be appreciated.
Here is result i am getting in controller and Library respectively
Array
(
[0] => Array
(
[value] => s�i�(�RTf���cBЉF� | �r�n#ô�
)
)
Array
(
[0] => Array
(
[value] =>
)
)
Check your character encoding; a place I worked at ran into a similar issue and it was due to our db trying to encode characters it did not support. UTF-8 generic is a, well, generic encoding type.
Edit:
Sorry I wasnt very clear with my first post. Ok I have text stored in the database, Id like to process it and look for any links to the products on my site and turn them into a fancy link. Below is 2 links and my current exp. The second link (Link2) Works as expected and passes the value 21 to detailsLink() My problem lies with Link1 it passes the value of 2 to detailsLink() not 21 as expected. I want to disregard the url completely as detailsLink() recreates the link with the product rating/cat etc. It should also work on http or https links.
Link1: http://192.168.2.22/dev/details.php?id=21
Link2: http://192.168.2.22/dev/details.php?id=21&module=info#Desc
$s = preg_replace("%(?<![=\]\'\"\w])https?://[^<>\s\'\",]*$ADDRESS\/details\.php\?id=([0-9]+)[^<>\s\'\",]+%ie", "detailsLink(\\1)", $s);
the value of $ADDRESS is 192.168.2.22/dev
No need to reinvent the wheel:
$url="http://192.168.2.22/dev/details.php?id=21&module=info#Desc";
parse_str(parse_url($url,PHP_URL_QUERY), $arr);
print_r($arr);
gives you:
Array
(
[id] => 21
[module] => info
)
parse_str()
parse_url()
I don't understand. Why don't you just use $_GET['id']?
EDIT: Never mind. I never knew about those functions! (parse_url, that is)