Jump to content

"for i in dicitionary" in php

Playlogo
Go to solution Solved by adampetre73,

I don't know any python, but in php you could do

foreach($dictionary as $item){
	// Your instructions here
}

or

foreach($dictionary as $item_key => $item){
	// Your instructions here
}

or

for($i=0; $i<=count($dictionary); $i++){
	// Your instructions here
}

Hope it helps

I wrote a little python script that creates dictionarys based on the user input. Now i want to convert this into php to run it on my server.聽

But i can't figur out how to conver this line :for i in dicionary:聽 into php 7.3

Does anyone have a solution?聽

Thanks for your answers in advance聽馃檭

!!RGB!!

Link to comment
Share on other sites

Link to post
Share on other sites

You're looking for the foreach statement.

foreach ($array as &$item) {
    print("Item: $item");
}

https://www.w3schools.com/php/php_looping_foreach.asp

"We're all in this together, might as well be friends" Tom, Toonami.

mini eLiXiVy: my open source 65% mechanical PCB, a build log, PCB anatomy and discussing open source licenses:聽https://linustechtips.com/topic/1366493-elixivy-a-65-mechanical-keyboard-build-log-pcb-anatomy-and-how-i-open-sourced-this-project/

mini_cardboard: a 4% keyboard build log and how keyboards work:聽https://linustechtips.com/topic/1328547-mini_cardboard-a-4-keyboard-build-log-and-how-keyboards-work/

Link to comment
Share on other sites

Link to post
Share on other sites

I don't know any python, but in php you could do

foreach($dictionary as $item){
	// Your instructions here
}

or

foreach($dictionary as $item_key => $item){
	// Your instructions here
}

or

for($i=0; $i<=count($dictionary); $i++){
	// Your instructions here
}

Hope it helps

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now