0
我會用幾個表格來獲取一個句子。PHP從數組中獲取密鑰
我的第一個數組:$ ARRAYTREE
[Choose] => RED
[a] => BLUE
[job] => ORANGE
[you] => YELLOW
[love] => GREEN
[,] => PURPLE
[and] => CYAN
[you] => YELLOW
[will] => BLACK
[never] => GREEN
[have] => BLACK
[to] => CYAN
[work] => ORANGE
[a] => BLUE
[day] => YELLOW
[in] => CYAN
[your] => YELLOW
[life] => ORANGE
[.] => PURPLE
值的變化:紫色,黑色
我設法從我的第一陣列(ARRAYTREE $)的話,得到了下面的句子:
"Choose a job you love "
我正在尋找一段時間,它是從這句話的結尾,尋找兩個值PURPLE和CYAN聯繫以實現轉換的存在。當找到這兩個值時,有必要獲取數組中的所有密鑰,直到達到新值(PURPLE或BLACK)時爲止。 隨着陣列2($ ARRAYTREE2),我會得到下面的話:
", go with all your heart "
我的第二個數組:$ ARRAYTREE2
[Wheresoever] => GREEN
[you] => YELLOW
[go] => BLACK
[,] => PURPLE
[go] => CYAN
[with] => GREEN
[all] => CYAN
[your] => YELLOW
[heart] => ORANGE
[.] => PURPLE
到底給予該字符串:
"Choose a job you love , go with all your heart "
我試着用array_search和array_slice的方法,但沒有結果...
感謝接受我的人...