{"id":1352,"date":"2014-08-09T23:14:09","date_gmt":"2014-08-10T03:14:09","guid":{"rendered":"http:\/\/www.jgarces.info\/?p=1352"},"modified":"2014-08-18T23:16:32","modified_gmt":"2014-08-19T03:16:32","slug":"array-spl","status":"publish","type":"post","link":"https:\/\/www.jgarces.info\/en\/array-spl\/","title":{"rendered":"Arrays with SPL"},"content":{"rendered":"<p>Using SPL to work with an array.<\/p>\n<pre lang=\"php\">\r\n\/* Arreglo *\/\r\n$personas = array(\"Carlos\", \"Carolina\", \"Jos\u00e9\",\r\n                  \"Manuel\", \"Sandra\");\r\n\r\ntry\r\n{\r\n\t\/* Creamos el objeto SPL *\/\r\n\t$arrayObjSPL = new ArrayObject($personas);\r\n\r\n\t\/* Modificamos el elemento 4 *\/\r\n\t$arrayObjSPL->offsetSet(4, \"Claudia\");\r\n\r\n\t\/* Eliminamos el elemento 2 *\/\r\n\t$arrayObjSPL->offsetUnset(2);\r\n\r\n\t\/* Iteramos sobre el arreglo con el objeto SPL *\/\r\n\tfor($iterator = $arrayObjSPL->getIterator();\t$iterator->valid();\t$iterator->next())\r\n\t{\r\n\t\t\/* Mostramos el elemento *\/\r\n\t\techo $iterator->key() . \" -> \" . $iterator->current() . \"<br \/>\";\r\n\t}\r\n}\r\ncatch (Exception $e)\r\n{\r\n\techo $e->getMessage();\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Using SPL to work with an array. \/* Arreglo *\/ $personas = array(&#8220;Carlos&#8221;, &#8220;Carolina&#8221;, &#8220;Jos\u00e9&#8221;, &#8220;Manuel&#8221;, &#8220;Sandra&#8221;); try { \/* Creamos el objeto SPL *\/ $arrayObjSPL = new ArrayObject($personas); \/* Modificamos el elemento 4 *\/ $arrayObjSPL->offsetSet(4, &#8220;Claudia&#8221;); \/* Eliminamos el elemento 2 *\/ $arrayObjSPL->offsetUnset(2); \/* Iteramos sobre el arreglo con el objeto SPL *\/ for($iterator [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[38],"class_list":["post-1352","post","type-post","status-publish","format-standard","hentry","category-php-development","tag-basic-programming"],"_links":{"self":[{"href":"https:\/\/www.jgarces.info\/en\/wp-json\/wp\/v2\/posts\/1352","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jgarces.info\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jgarces.info\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jgarces.info\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jgarces.info\/en\/wp-json\/wp\/v2\/comments?post=1352"}],"version-history":[{"count":1,"href":"https:\/\/www.jgarces.info\/en\/wp-json\/wp\/v2\/posts\/1352\/revisions"}],"predecessor-version":[{"id":1353,"href":"https:\/\/www.jgarces.info\/en\/wp-json\/wp\/v2\/posts\/1352\/revisions\/1353"}],"wp:attachment":[{"href":"https:\/\/www.jgarces.info\/en\/wp-json\/wp\/v2\/media?parent=1352"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jgarces.info\/en\/wp-json\/wp\/v2\/categories?post=1352"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jgarces.info\/en\/wp-json\/wp\/v2\/tags?post=1352"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}