PHP: an array in an array. Search in PHP array

- . , - . . , . PHP , . , , .

, . - . ; , . .

PHP . , .

public $aNone = array(); //

public $aFact = array('', '', ''); //

- :

$cSrcLine = ' ';

for ($i=0; $i<13; $i++) {

$cUserLine = inputUserLine(); // -

if (checkFunc($cSrcLine, $cUserLine) {

$aResult[] = 'Yes'; // PHP

} else {

$aResult[] = 'No';

}

}

13 , 'Yes' 'No'. 0 12. , "" PHP- :





$cFutureArray = '';

for ($i=0; $i<13; $i++) {

$cUserLine = inputUserLine(); // -

if ($i > 0) { $cFutureArray .= '|'; }

if (checkFunc($cSrcLine, $cUserLine) { $cFutureArray .= 'Yes';

} else { $cFutureArray .= 'No'; }

}

$aResult = explode('|', $cFutureArray);

php array to string




() « ». , , , . "PHP- ", : . , :

return array(

'view_manager' => array(41, 'template_path_stack' => array( __DIR__ . '/../view', ),

'router' => array('routes' => array('sayhello' => array(

'type' => 'Zend\Mvc\Router\Http\Literal',

'options' => array('route' => '/sayhello', 'defaults' => array(

'controller' => 'Helloworld\Controller\Index', 'action' => 'index',))))),

'controllers' => array('invokables' => array(

'Helloworld\Controller\Index' => 'Helloworld\Controller\IndexController'))









);

«PHP- » ZF 2. , , , ( ZendSkeletonApplication/module/Helloworld/config/module.config.php).

remove php array element




- . - , - . , - , , - .

,

php , - . PHP . , , . PHP ( ) .

- . , , ... .

PHP : . , . , , .

, , - - . , .

- "[" "]", : $aSrcData[1][2] [2] [1], $aSrcData. PHP . .

- , , , , , . () , , :

$aAnketa['name'] = '';

$aAnketa['age'] = 42;

$aAnketa['work'] = '';

$aAnketa['active'] = true;

$aTable[] = $aAnketa;



$aAnketa['name'] = '';

$aAnketa['age'] = 34;

$aAnketa['work'] = '';

$aAnketa['active'] = true;

$aTable[] = $aAnketa;



$aAnketa['name'] = '';

$aAnketa['age'] = 28;

$aAnketa['work'] = '';

$aAnketa['active'] = false;

$aTable[] = $aAnketa;

$sOne .= implode ("; ", $aTable[1]) . '<br/>'; // PHP-

$sOne .= $aTable[1]['work']; //

( - , 0, - , : 'name', 'age', 'work', 'active'):

$sOne = '; 34; ; 1<br/>';

, . , , .

, , , ... "PHP- " , . - - .

search in php array




, , , , , , . , . "" , PHP - . . ( PHP ) 0, 1, 2, ... , "" .

$aLine[""] = ""; // PHP- = ""

( ):

$aLine[iconv ('UTF-8', 'CP1251', "")] = iconv ('UTF-8', 'CP1251', "");

$aLine :

$aLine[] = iconv ('UTF-8', 'CP1251', '');

$aLine[iconv ('UTF-8', 'CP1251', "")] = iconv ('UTF-8', 'CP1251', "");

$aLine[] = iconv ('UTF-8', 'CP1251', '');

:

foreach ($aLine as $ck => $cv) {

$cOne .= $ck . '=' . $cv . '<br/>';

}

:

=

0=

=

1=

PHP- '' '' 0, .

php remove array




PHP . , , , , , .

. :

unset($aLine[0]); // PHP

:

=

=

1=

. , : implode() explode(), PHP- , - .

PHP , : unset($aLine);

.

PHP array_keys(), array_values(), array_key_exists(), in_array(), , PHP .

php array key




, , . , .

PHP , . PHPWord, MS Word:

$elements = array('Text', 'Inline', 'TextRun', 'Link', 'PreserveText', 'TextBreak',

'ListItem', 'ListItemRun', 'Table', 'Image', 'Object', 'Footnote',

'Endnote', 'CheckBox', 'TextBox', 'Field', 'Line');

$functions = array();

for ($i = 0; $i < count($elements); $i++) {

$functions[$i] = 'add' . $elements[$i];

}

$functions $elements, , .

$elements[4] $functions[4], .

, PHP : sort(), rsort(), asort(), ksort(), ... . - shuffle().

php value in array




PHP , , , . , , , , .

php array in array




, , - . .

implode() explode() . .

, , . , , .

$cSrcLine = 'Text Text ListItemRun TextBox ListItem TextBox Check Box CheckBox TextBox Footnote';

$aSrc = explode(' ', $cSrcLine);

$cDstLine = '';

for ($i=0; $i < count($aSrc); $i++) {

$cFind = '[' . $aSrc[$i] . ']';

if ( ! is_integer(strpos($cDstLine, $cFind))) {

$cDstLine .= $cFind;

}

}

$aDst = explode('][', $cDstLine);



$cOne = implode('; ', $aDst);

$cOne , : "Text; ListItemRun; TextBox; ListItem; Check; Box; CheckBox; Footnote".

, , . , , a-z, , , . PHP « » "", .

PHP - , , , , .

PHP

, PHP - , « » , , . , .

« , , , » . PHP- «», , .




All Articles